Guest User

Untitled

a guest
Oct 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. {-# language DeriveGeneric #-}
  2. {-# language TypeFamilies #-}
  3. {-# language TypeOperators #-}
  4. {-# language PatternSynonyms #-}
  5.  
  6. import Data.Text
  7. import qualified GHC.Generics as GHC
  8. import Generics.SOP
  9. import Text.Read
  10.  
  11. data Foo = Foo { x :: Int, y :: Text } deriving (Show, GHC.Generic)
  12.  
  13. instance Generic Foo
  14.  
  15. pattern Foo' :: t Int -> t Text -> SOP t (Code Foo)
  16. pattern Foo' {x', y'} = SOP (Z (x' :* y' :* Nil))
  17.  
  18. readFooMaybe :: SOP (IO :.: Maybe) (Code Foo)
  19. readFooMaybe = Foo'
  20. {
  21. x' = Comp (fmap readMaybe getLine)
  22. , y' = Comp (fmap readMaybe getLine)
  23. }
  24.  
  25. main :: IO ()
  26. main = do
  27. r <- hsequence' readFooMaybe
  28. print r
Add Comment
Please, Sign In to add comment