From 695fdf2b2ca2562b7d30c2bb4a140c0616e14aa6 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 6 Sep 2019 08:24:10 -0700 Subject: [ibb] refactor aero/Ibb --- lore/Biz/Ibb/Move.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lore/Biz/Ibb') 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 -- cgit v1.2.3