diff options
author | Ben Sima <ben@bsima.me> | 2019-09-06 08:24:10 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-09-06 08:24:10 -0700 |
commit | 695fdf2b2ca2562b7d30c2bb4a140c0616e14aa6 (patch) | |
tree | 36b03114a5d45bd8fee3c2cb45bfcf5afca9cfd5 | |
parent | 96b232c6e21710a1b0e79946de09bef7890429db (diff) |
[ibb] refactor aero/Ibb
-rw-r--r-- | aero/Ibb.hs | 5 | ||||
-rw-r--r-- | lore/Biz/Ibb/Move.hs | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/aero/Ibb.hs b/aero/Ibb.hs index f7ee2af..705abef 100644 --- a/aero/Ibb.hs +++ b/aero/Ibb.hs @@ -6,8 +6,9 @@ module Ibb where import Alpha -import Biz.Ibb.Move -import Miso +import Biz.Ibb.Move (move) +import Biz.Ibb.Core (Action(..), see, init) +import Miso (App(..), defaultEvents, miso) main :: IO () main = miso $ \u -> App { model = init u, .. } diff --git a/lore/Biz/Ibb/Move.hs b/lore/Biz/Ibb/Move.hs index c2adea1..0d83e8a 100644 --- a/lore/Biz/Ibb/Move.hs +++ b/lore/Biz/Ibb/Move.hs @@ -3,8 +3,7 @@ -- | App update logic module Biz.Ibb.Move ( - module Core - , move + move -- * Server interactions , fetchPeople ) where @@ -21,7 +20,7 @@ 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 <# do SetPeople /@ fetchPeople +move FetchPeople m = m <# (SetPeople /@ fetchPeople) move (SetPeople ps) m = noEff m { people = ps } fetchPeople :: IO (WebData [Core.Person]) @@ -30,11 +29,13 @@ fetchPeople = do case mjson of Nothing -> pure $ Failure "could not read from server" Just a -> pure - $ either (Failure . ms) Network.RemoteData.Success + $ fromEither + $ either (Left . ms) pure $ eitherDecodeStrict a where req = Request { reqMethod = GET - , reqURI = "/api/people" -- FIXME: can replace this hardcoding with a function? + -- FIXME: can replace this hardcoding with a function? + , reqURI = "/api/people" , reqLogin = Nothing , reqHeaders = [] , reqWithCredentials = False |