Closed FranklinChen closed 7 years ago
I'd happily take a pull request to change the example to something more neutral.
Regarding an improvement to this example, would you consider it enough that there is a non-partial function in place of fromJust
e.g.
-- The Reader monad, which implements this complicated check.
calc_isCountCorrect :: Reader Bindings Bool
calc_isCountCorrect = do
count <- asks (lookupVar "count")
bindings <- ask
return . boolM $ ((== (Map.size bindings)) <$> count )
-- Not really a good idea?
boolM :: Maybe Bool -> Bool
boolM Nothing = False
boolM (Just b) = b
We could just call maybe
appropriately instead.
Merged
Reader.hs
documentation has an example that makes me very uneasy because it usesfromJust
. I think code snippets make a big impression on newcomers and the example code to illustrateReader
is not anything anyone would really write because it doesn't account for errors.