on master help sign in
[skeleton] Move most backend/frontend functionality to libraries
commit7dd148befab61a7288469f98a370d26fb3dd52f3 authorLuigy Leon <luigy@outlook.com> dateMon 23 Apr 2018, 12:17 (9 years ago) parentb9e3baf
7 files changed+56−23
lib/command/src/Obelisk/Command/Repl.hs+3−2 skeleton/backend/backend.cabal+14−5 skeleton/backend/src/Backend/App.hs+7 skeleton/backend/src/main.hs+3−3 skeleton/frontend/frontend.cabal+15−5 skeleton/frontend/src/Frontend/App.hs+12 skeleton/frontend/src/main.hs+2−8
lib/command/src/Obelisk/Command/Repl.hs+3−2
@@ -10,8 +10,9 @@ import Obelisk.Command.Project
1010
1111-- | Run an interactive repl within a given path
1212runRepl :: FilePath -> IO ()
13−runRepl dir = inProjectShell "ghc" $ "cd " <> dir <> "; cabal new-repl " <> dir
13+runRepl dir = inProjectShell "ghc" $ "cd " <> dir <> "; cabal new-repl"
1414
1515-- | Watch the given directory for errors and warnings
1616watch :: FilePath -> IO ()
17−watch dir = inProjectShell "ghc" $ "cd " <> dir <> "; ghcid -W -c'cabal new-repl " <> dir <> "'"
17+watch dir = inProjectShell "ghc" $ "cd " <> dir <> "; ghcid -W --command='cabal new-repl'"
18+
skeleton/backend/backend.cabal+14−5
@@ -1,12 +1,21 @@
11name: backend
22version: 0.1
3−cabal-version: >= 1.2
3+cabal-version: >= 1.8
44build-type: Simple
55
6+library
7+ hs-source-dirs: src
8+ build-depends: base
9+ , common
10+ , obelisk-backend
11+ exposed-modules:
12+ Backend.App
13+ ghc-options: -Wall
14+
615executable backend
716 main-is: main.hs
817 hs-source-dirs: src
9− build-depends:
10− base,
11− common,
12− obelisk-backend
18+ build-depends: base
19+ , backend
20+ , common
21+ , obelisk-backend
skeleton/backend/src/Backend/App.hsnew file+7
@@ -0,0 +1,7 @@
1+module Backend.App where
2+
3+import Common.Api
4+import qualified Obelisk.Backend as Ob
5+
6+backend :: IO ()
7+backend = Ob.backend Ob.def
skeleton/backend/src/main.hs+3−3
@@ -1,5 +1,5 @@
1−import Obelisk.Backend
2−import Common.Api
1+import Backend.App
32
43main :: IO ()
5−main = backend def
4+main = backend
5+
skeleton/frontend/frontend.cabal+15−5
@@ -1,14 +1,24 @@
11name: frontend
22version: 0.1
3−cabal-version: >= 1.2
3+cabal-version: >= 1.8
44build-type: Simple
55
6+library
7+ hs-source-dirs: src
8+ build-depends: base
9+ , reflex-dom
10+ , static
11+ , text
12+ exposed-modules:
13+ Frontend.App
14+ ghc-options: -Wall
15+
616executable frontend
717 main-is: main.hs
818 hs-source-dirs: src
9− build-depends: base,
10− reflex-dom,
11− text,
12− static
19+ build-depends: base
20+ , reflex-dom
21+ , static
22+ , frontend
1323 --TODO: Make these ghc-options optional
1424 ghc-options: -threaded
skeleton/frontend/src/Frontend/App.hsnew file+12
@@ -0,0 +1,12 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE TypeApplications #-}
3+{-# LANGUAGE DataKinds #-}
4+module Frontend.App where
5+
6+import Reflex.Dom
7+import Static
8+
9+frontend :: IO ()
10+frontend = mainWidget $ do
11+ text "Welcome to Obelisk!"
12+ elAttr "img" ("src" =: static @"obelisk.jpg") blank
skeleton/frontend/src/main.hs+2−8
@@ -1,10 +1,4 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−{-# LANGUAGE TypeApplications #-}
3−{-# LANGUAGE DataKinds #-}
4−import Reflex.Dom
5−import Static
1+import Frontend.App
62
73main :: IO ()
8−main = mainWidget $ do
9− text "Welcome to Obelisk!"
10− elAttr "img" ("src" =: static @"obelisk.jpg") blank
4+main = frontend