aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2017-04-04 23:40:54 +0200
committerJoris2017-04-04 23:42:42 +0200
commitf6a73e5bd6a5e2d7d4eb9c8a14bdf1a0c8a4ac4c (patch)
tree184b0ef41ad60dcc9e5cc927604c031e0db81bbf /src
parent6228c242fda7b33bc919f2a74509314d1e671d4b (diff)
Bootstrap purescript
Diffstat (limited to 'src')
-rw-r--r--src/Aliment.purs13
-rw-r--r--src/Main.purs13
-rw-r--r--src/Page.purs45
3 files changed, 71 insertions, 0 deletions
diff --git a/src/Aliment.purs b/src/Aliment.purs
new file mode 100644
index 0000000..e7c4fc8
--- /dev/null
+++ b/src/Aliment.purs
@@ -0,0 +1,13 @@
+module Aliment where
+
+all :: Array Aliment
+all =
+ [ { name: "Oignon", gi: 15 }
+ , { name: "Olive", gi: 15 }
+ , { name: "Haricot rouge", gi: 35 }
+ ]
+
+type Aliment =
+ { name :: String
+ , gi :: Int
+ }
diff --git a/src/Main.purs b/src/Main.purs
new file mode 100644
index 0000000..3121aa5
--- /dev/null
+++ b/src/Main.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Prelude
+import Control.Monad.Eff (Eff)
+import Halogen.Aff as HA
+import Halogen.VDom.Driver (runUI)
+
+import Page as Page
+
+main :: Eff (HA.HalogenEffects ()) Unit
+main = HA.runHalogenAff do
+ body <- HA.awaitBody
+ runUI Page.component unit body
diff --git a/src/Page.purs b/src/Page.purs
new file mode 100644
index 0000000..83e4d73
--- /dev/null
+++ b/src/Page.purs
@@ -0,0 +1,45 @@
+module Page where
+
+import Prelude
+import Data.Maybe (Maybe(..))
+import Halogen as H
+import Halogen.HTML as HH
+
+import Aliment as Aliment
+import Aliment (Aliment)
+
+type State = Unit
+
+data Query a = NoOp a
+
+data Message = Toggled Boolean
+
+component :: forall m . H.Component HH.HTML Query State Message m
+component =
+ H.component
+ { initialState: const unit
+ , render
+ , eval
+ , receiver: const Nothing
+ }
+ where
+ render :: State -> H.ComponentHTML Query
+ render state =
+ HH.div
+ []
+ [ HH.h1 [] [ HH.text "Sucre" ]
+ , HH.ul
+ []
+ (map renderAliment Aliment.all)
+ ]
+
+ eval :: Query ~> H.ComponentDSL State Query Message m
+ eval = case _ of
+ NoOp next -> pure next
+
+renderAliment :: Aliment -> H.ComponentHTML Query
+renderAliment aliment =
+ HH.li
+ []
+ [ HH.text (aliment.name <> ", index glycémique: " <> (show aliment.gi))
+ ]