Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# language DeriveGeneric #-}
- {-# language TypeFamilies #-}
- {-# language TypeOperators #-}
- {-# language PatternSynonyms #-}
- import Data.Text
- import qualified GHC.Generics as GHC
- import Generics.SOP
- import Text.Read
- data Foo = Foo { x :: Int, y :: Text } deriving (Show, GHC.Generic)
- instance Generic Foo
- pattern Foo' :: t Int -> t Text -> SOP t (Code Foo)
- pattern Foo' {x', y'} = SOP (Z (x' :* y' :* Nil))
- readFooMaybe :: SOP (IO :.: Maybe) (Code Foo)
- readFooMaybe = Foo'
- {
- x' = Comp (fmap readMaybe getLine)
- , y' = Comp (fmap readMaybe getLine)
- }
- main :: IO ()
- main = do
- r <- hsequence' readFooMaybe
- print r
Add Comment
Please, Sign In to add comment