Last active
August 29, 2015 14:02
-
-
Save nobsun/4c2413a71a0d6640e75c to your computer and use it in GitHub Desktop.
リストを(非)正格に構成する
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 I a = I {unI :: a} | |
instance Functor I where | |
fmap f (I a) = I (f a) | |
instance Monad I where | |
return = I | |
I x >>= f = f x | |
foo :: [I a] -> I [a] | |
foo [] = return [] | |
foo (ix:ixs) = do { x <- ix; xs <- foo ixs; return (x:xs) } | |
bar :: [I a] -> I [a] | |
bar = return . map unI | |
ss :: [I ()] | |
ss = repeat (I undefined) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment