Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generics.Eot.Tutorial
- namesOfFields :: HasEot a => Proxy a -> [String]
- data A
- data B
- class EotSerialize eot where
- class Serialize a where
- genericSerialize :: (HasEot a, EotSerialize (Eot a)) => a -> [Int]
- class EotDeserialize eot where
- class Deserialize a where
- genericDeserialize :: (HasEot a, EotDeserialize (Eot a)) => [Int] -> a
- class EotCreateTableStatement meta eot where
- createTableStatement :: forall a. (HasEot a, EotCreateTableStatement Datatype (Eot a)) => Proxy a -> String
- data Person = Person {}
- data NoSelectors = NotSupported Int Bool
- class ToString a where
- class ToString2 a where
- data C = C1 Int String
Documentation
namesOfFields :: HasEot a => Proxy a -> [String] #
>>>
namesOfFields (Proxy :: Proxy A)
["foo","bar","baz"]
>>>
:kind! Eot B
Eot B :: * = Either (Int, ()) (Either ([Char], (Bool, ())) (Either () Void))
class EotSerialize eot where #
Minimal complete definition
Methods
eotSerialize :: Int -> eot -> [Int] #
Instances
EotSerialize () # | |
EotSerialize Void # | |
(EotSerialize this, EotSerialize next) => EotSerialize (Either this next) # | |
(Serialize x, EotSerialize xs) => EotSerialize (x, xs) # | |
genericSerialize :: (HasEot a, EotSerialize (Eot a)) => a -> [Int] #
>>>
genericSerialize (A1 "foo" 42)
[0,3,102,111,111,1,42]>>>
genericSerialize (A2 23 True)
[1,1,23,1,1]
class EotDeserialize eot where #
Minimal complete definition
Methods
eotDeserialize :: [Int] -> eot #
Instances
EotDeserialize () # | |
EotDeserialize Void # | |
(EotDeserialize this, EotDeserialize next) => EotDeserialize (Either this next) # | |
(Deserialize x, EotDeserialize xs) => EotDeserialize (x, xs) # | |
genericDeserialize :: (HasEot a, EotDeserialize (Eot a)) => [Int] -> a #
>>>
genericDeserialize [0,3,102,111,111,1,42] :: A
A1 {foo = "foo", bar = 42}>>>
genericDeserialize [1,1,23,1,1] :: A
A2 {bar = 23, baz = True}
>>>
(genericDeserialize $ genericSerialize $ A1 "foo" 42) :: A
A1 {foo = "foo", bar = 42}
class EotCreateTableStatement meta eot where #
Minimal complete definition
Methods
eotCreateTableStatement :: meta -> Proxy eot -> [String] #
Instances
EotCreateTableStatement [String] fields => EotCreateTableStatement Datatype (Either fields Void) # | |
EotCreateTableStatement [String] () # | |
(Typeable * x, EotCreateTableStatement [String] xs) => EotCreateTableStatement [String] (x, xs) # | |
createTableStatement :: forall a. (HasEot a, EotCreateTableStatement Datatype (Eot a)) => Proxy a -> String #
>>>
putStrLn $ createTableStatement (Proxy :: Proxy Person)
CREATE TABLE Person COLUMNS (name [Char], age Int);
>>>
putStrLn $ createTableStatement (Proxy :: Proxy A)
... • No instance for (EotCreateTableStatement Datatype (Either ([Char], (Int, ())) (Either (Int, (Bool, ())) Void))) arising from a use of ‘createTableStatement’ ...
data NoSelectors #
Constructors
NotSupported Int Bool |
Instances
Generic NoSelectors # | |
type Rep NoSelectors # | |
>>>
putStrLn $ createTableStatement (Proxy :: Proxy NoSelectors)
*** Exception: constructor NotSupported has no selectors, this is not supported ...
>>>
toString2 (42 :: Int)
"42"
>>>
serialize (C1 42 "yay!")
[0,1,42,4,121,97,121,33]