Created
March 28, 2018 18:37
-
-
Save vvv/aa1dd417d514937329cdf86b6ffb2d5d to your computer and use it in GitHub Desktop.
Looking for idiomatic way to write expression with `Applicative`
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
#!/usr/bin/env stack | |
-- stack --resolver lts-11.2 script | |
{-# OPTIONS_GHC -Wall -W -Werror #-} | |
data Foo = Foo | |
{ fooInt :: Int | |
, fooBar :: Bar | |
} deriving Show | |
data Bar = Bar Baz | |
deriving Show | |
data Baz = Baz | |
{ bazInt :: Int | |
, bazChr :: Char | |
, bazStr :: String | |
} deriving Show | |
main :: IO () | |
main = do | |
foo <- Foo <$> pure 42 | |
<*> (Bar <$> (Baz <$> pure 13 | |
<*> pure 'c' | |
<*> pure "whatever" | |
) | |
) | |
print foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment