Last active
June 21, 2017 21:56
-
-
Save Steell/5c8f6b2f6d2f5b62c8e7e70f711fca2e to your computer and use it in GitHub Desktop.
MonadReader + Lens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Foo a = Foo { _unFoo :: a } | |
makeLenses ''Foo | |
newtype Newline = Newline { unNewline :: String } | |
instance Monoid Newline where | |
mempty = Newline [] | |
mappend (Newline []) b = b | |
mappend a (Newline []) = a | |
mappend (Newline a) (Newline b) = Newline $ a `mappend` "\n" `mappend` b | |
printAll :: ReaderT (Foo (Seq (Foo String))) IO | |
printAll = | |
putStrLn =<< unNewline <$> view (unFoo.folded.unFoo.to Newline) |
glguy
commented
Jun 21, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment