From f4b8c0df041b063c0b47d2ec6c818a9c202fd833 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 15 Apr 2020 09:54:10 -0700 Subject: Re-namespacing Moving away from the DNS-driven namespacing toward more condensed names, mostly because I don't like typing so much. --- Biz/Ibb/Move.hs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Biz/Ibb/Move.hs (limited to 'Biz/Ibb/Move.hs') diff --git a/Biz/Ibb/Move.hs b/Biz/Ibb/Move.hs new file mode 100644 index 0000000..1e635ac --- /dev/null +++ b/Biz/Ibb/Move.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedStrings #-} + +-- | App update logic +module Biz.Ibb.Move + ( move + -- * Server interactions + , fetchPeople + ) +where + +import Alpha +import Biz.Ibb.Core as Core +import Network.RemoteData +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 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 + } -- cgit v1.2.3