summaryrefslogtreecommitdiff
path: root/com/influencedbybooks/move.hs
diff options
context:
space:
mode:
Diffstat (limited to 'com/influencedbybooks/move.hs')
-rw-r--r--com/influencedbybooks/move.hs43
1 files changed, 0 insertions, 43 deletions
diff --git a/com/influencedbybooks/move.hs b/com/influencedbybooks/move.hs
deleted file mode 100644
index 6623d6f..0000000
--- a/com/influencedbybooks/move.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
-
--- | App update logic
-module Com.Influencedbybooks.Move (
- move
- -- * Server interactions
- , fetchPeople
- ) where
-
-import Com.Simatime.Alpha
-import Data.Aeson
-import Com.Influencedbybooks.Core as Core
-import JavaScript.Web.XMLHttpRequest (Request(..), Method(GET), RequestData(NoData), contents, xhrByteString)
-import Miso
-import Miso.String
-import Com.Simatime.Network
-
-move :: Action -> Model -> Effect Action Model
-move Nop m = noEff m
-move (HandleRoute u) m = m { uri = u } <# pure Nop
-move (ChangeRoute u) m = m <# do pushURI u >> pure Nop
-move FetchPeople m = m <# (SetPeople /@ fetchPeople)
-move (SetPeople ps) m = noEff m { people = ps }
-
-fetchPeople :: IO (WebData [Core.Person])
-fetchPeople = do
- mjson <- contents /@ xhrByteString req
- case mjson of
- Nothing -> pure $ Failure "could not read from server"
- Just a -> pure
- $ fromEither
- $ either (Left . ms) pure
- $ eitherDecodeStrict a
- where
- req = Request { reqMethod = GET
- -- FIXME: can replace this hardcoding with a function?
- , reqURI = "/api/people"
- , reqLogin = Nothing
- , reqHeaders = []
- , reqWithCredentials = False
- , reqData = NoData
- }