mirror of
https://github.com/qfpl/applied-fp-course.git
synced 2024-11-23 03:44:45 +03:00
Made the code a little less $ happy
This commit is contained in:
parent
0aa03de8f1
commit
7dc32df03c
@ -114,7 +114,7 @@ makeConfig pc = Conf
|
||||
-- sections. Sometimes the compiler might need a bit of help, or you would
|
||||
-- like to be explicit in your intentions.
|
||||
lastToEither e g =
|
||||
maybe (Left e) Right . getLast $ g pc
|
||||
maybe (Left e) Right (getLast (g pc))
|
||||
|
||||
-- This is the function we'll actually export for building our configuration.
|
||||
-- Since it wraps all our efforts to read information from the command line, and
|
||||
@ -160,7 +160,7 @@ parseJSONConfigFile fp = do
|
||||
-> Last b
|
||||
fromObj k c obj =
|
||||
-- Too weird ?
|
||||
Last $ c <$> Aeson.parseMaybe (Aeson..: k) obj
|
||||
Last (c <$> Aeson.parseMaybe (Aeson..: k) obj)
|
||||
|
||||
-- Use bracket to save ourselves from horrible exceptions, which are
|
||||
-- horrible.
|
||||
@ -170,7 +170,7 @@ parseJSONConfigFile fp = do
|
||||
:: IO (Maybe Aeson.Object)
|
||||
readObject = bracketOnError
|
||||
(LBS.readFile fp)
|
||||
(const ( pure Nothing ))
|
||||
(pure . const Nothing)
|
||||
(pure . Aeson.decode)
|
||||
|
||||
-- | Command Line Parsing
|
||||
|
@ -39,10 +39,9 @@ main = do
|
||||
flushTopic = do
|
||||
-- To lift our AppM into the base IO, we run it as would if it were
|
||||
-- a normal AppM, returning our IO ( Either ) result.
|
||||
r <- AppM.runAppM env $ do
|
||||
r <- AppM.runAppM env $
|
||||
-- This inner 'do' is running as if it were an AppM, including all of the nice error handling etc.
|
||||
t <- AppM.throwL $ Types.mkTopic testTopic
|
||||
DB.deleteTopic t
|
||||
AppM.throwL (Types.mkTopic testTopic) >>= DB.deleteTopic
|
||||
-- This outer 'do' is in the base IO monad and if we have a failure
|
||||
-- here we need to exit with an error code to ensure the test-suite
|
||||
-- knows to fail our tests.
|
||||
|
Loading…
Reference in New Issue
Block a user