mirror of
https://github.com/qfpl/applied-fp-course.git
synced 2024-11-23 03:44:45 +03:00
Level07 wording changes.
This commit is contained in:
parent
52b9bbae42
commit
dc7bff1ace
@ -91,9 +91,6 @@ data Env = Env
|
||||
--
|
||||
-- But ExceptT has an `m` type variable, so what do we put there?
|
||||
--
|
||||
-- The answer is to put the IO that we replaced as the base monad for ExceptT.
|
||||
--
|
||||
-- This gives us the final AppM looking like:
|
||||
newtype AppM a = AppM
|
||||
{ unAppM :: _ }
|
||||
deriving ( Functor
|
||||
@ -106,17 +103,17 @@ newtype AppM a = AppM
|
||||
, MonadError Error
|
||||
)
|
||||
|
||||
-- Now that we've two transfomers in out 'stack', we have to 'run' them in order
|
||||
-- to effect the computations and produce our result in our base monad. When
|
||||
-- you're running monad transformers you have to unpack them in order. Since our outer
|
||||
-- transformer is a ReaderT, we have to run that first. Followed by running
|
||||
-- the ExceptT to retrieve our `IO (Either Error a)`.
|
||||
runAppM
|
||||
:: Env
|
||||
-> AppM a
|
||||
-> IO (Either Error a)
|
||||
runAppM env appM =
|
||||
error "runAppM not reimplemented"
|
||||
-- Now that we've two transfomers in out 'stack', we have to 'run' them in order
|
||||
-- to effect the computations and produce our result in our base monad. When
|
||||
-- you're running monad transformers you have to unpack them in order. Since our outer
|
||||
-- transformer is a ReaderT, we have to run that first. Followed by running
|
||||
-- the ExceptT to retrieve our `IO (Either Error a)`.
|
||||
|
||||
-- This is a helper function that will `lift` an Either value into our new AppM
|
||||
-- by applying `throwError` to the Left value, and using `pure` to lift the
|
||||
|
@ -147,6 +147,11 @@ parseJSONConfigFile fp = do
|
||||
( fromObj "dbFilePath" id cObj )
|
||||
|
||||
-- Parse out the keys from the object, maybe...
|
||||
-- >>> fromObj "foo" id (encode "{\"foo\":\"Susan\"}")
|
||||
-- Last (Just "Susan")
|
||||
-- >>> fromObj "foo" id (encode "{\"bar\":33}")
|
||||
-- Last Nothing
|
||||
--
|
||||
fromObj
|
||||
:: FromJSON a
|
||||
=> Text
|
||||
|
@ -47,7 +47,8 @@ data Comment = Comment
|
||||
, commentText :: CommentText
|
||||
, commentTime :: UTCTime
|
||||
}
|
||||
-- Generic has been added to our deriving list.
|
||||
-- Generic has been added to our deriving list. This will require the
|
||||
-- DeriveGeneric pragma to be added to the top of the file
|
||||
deriving ( Show, Generic )
|
||||
|
||||
instance ToJSON Comment where
|
||||
|
Loading…
Reference in New Issue
Block a user