summaryrefslogtreecommitdiff
path: root/Com/InfluencedByBooks/Move.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-04-15 09:54:10 -0700
committerBen Sima <ben@bsima.me>2020-04-15 10:06:56 -0700
commitf4b8c0df041b063c0b47d2ec6c818a9c202fd833 (patch)
tree01ad246a83fda29c079847b3397ca6509a7f6106 /Com/InfluencedByBooks/Move.hs
parent6ed475ca94209ce92e75f48764cb9d361029ea26 (diff)
Re-namespacing
Moving away from the DNS-driven namespacing toward more condensed names, mostly because I don't like typing so much.
Diffstat (limited to 'Com/InfluencedByBooks/Move.hs')
-rw-r--r--Com/InfluencedByBooks/Move.hs48
1 files changed, 0 insertions, 48 deletions
diff --git a/Com/InfluencedByBooks/Move.hs b/Com/InfluencedByBooks/Move.hs
deleted file mode 100644
index 5d6f0c4..0000000
--- a/Com/InfluencedByBooks/Move.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
-
--- | App update logic
-module Com.InfluencedByBooks.Move
- ( move
- -- * Server interactions
- , fetchPeople
- )
-where
-
-import Alpha
-import Com.InfluencedByBooks.Core as Core
-import Com.Simatime.Network
-import Data.Aeson
-import JavaScript.Web.XMLHttpRequest ( Request(..)
- , Method(GET)
- , RequestData(NoData)
- , contents
- , xhrByteString
- )
-import Miso
-import Miso.String
-
-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
- }