{-# LANGUAGE DeriveFoldable     #-}
{-# LANGUAGE DeriveFunctor      #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE DeriveTraversable  #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia        #-}
{-# LANGUAGE FlexibleInstances  #-}
{-# LANGUAGE StrictData         #-}
module Data.Schema.Type
    ( SchemaF (..)
    , Schema
    , Type (..)
    , sumType
    , prodType
    ) where

import           Control.Applicative          ((<|>))
import           Data.Fix                     (Fix (..))
import           Data.Functor.Classes         (Eq1, Read1, Show1)
import           Data.Functor.Classes.Generic (FunctorClassesDefault (..))
import           GHC.Generics                 (Generic, Generic1)


data Type
    = TyBool
    | TyWord8
    | TyWord16
    | TyWord32
    | TyWord64
    | TyBin
    | TyFixedBin Int
    | TyName String
    deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
(Int -> Type -> ShowS)
-> (Type -> String) -> ([Type] -> ShowS) -> Show Type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> String
$cshow :: Type -> String
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Show, ReadPrec [Type]
ReadPrec Type
Int -> ReadS Type
ReadS [Type]
(Int -> ReadS Type)
-> ReadS [Type] -> ReadPrec Type -> ReadPrec [Type] -> Read Type
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Type]
$creadListPrec :: ReadPrec [Type]
readPrec :: ReadPrec Type
$creadPrec :: ReadPrec Type
readList :: ReadS [Type]
$creadList :: ReadS [Type]
readsPrec :: Int -> ReadS Type
$creadsPrec :: Int -> ReadS Type
Read, Type -> Type -> Bool
(Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Eq)

type DatatypeName = (String, String)

data SchemaF a
    = Empty
    | Atom Type
    | List a

    | Prod [a]
    | Field String a

    | Sum (Maybe DatatypeName) [a]
    | Con String a

    | Module String [a]
    | Schema [a]
    deriving (Int -> SchemaF a -> ShowS
[SchemaF a] -> ShowS
SchemaF a -> String
(Int -> SchemaF a -> ShowS)
-> (SchemaF a -> String)
-> ([SchemaF a] -> ShowS)
-> Show (SchemaF a)
forall a. Show a => Int -> SchemaF a -> ShowS
forall a. Show a => [SchemaF a] -> ShowS
forall a. Show a => SchemaF a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaF a] -> ShowS
$cshowList :: forall a. Show a => [SchemaF a] -> ShowS
show :: SchemaF a -> String
$cshow :: forall a. Show a => SchemaF a -> String
showsPrec :: Int -> SchemaF a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SchemaF a -> ShowS
Show, ReadPrec [SchemaF a]
ReadPrec (SchemaF a)
Int -> ReadS (SchemaF a)
ReadS [SchemaF a]
(Int -> ReadS (SchemaF a))
-> ReadS [SchemaF a]
-> ReadPrec (SchemaF a)
-> ReadPrec [SchemaF a]
-> Read (SchemaF a)
forall a. Read a => ReadPrec [SchemaF a]
forall a. Read a => ReadPrec (SchemaF a)
forall a. Read a => Int -> ReadS (SchemaF a)
forall a. Read a => ReadS [SchemaF a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaF a]
$creadListPrec :: forall a. Read a => ReadPrec [SchemaF a]
readPrec :: ReadPrec (SchemaF a)
$creadPrec :: forall a. Read a => ReadPrec (SchemaF a)
readList :: ReadS [SchemaF a]
$creadList :: forall a. Read a => ReadS [SchemaF a]
readsPrec :: Int -> ReadS (SchemaF a)
$creadsPrec :: forall a. Read a => Int -> ReadS (SchemaF a)
Read, SchemaF a -> SchemaF a -> Bool
(SchemaF a -> SchemaF a -> Bool)
-> (SchemaF a -> SchemaF a -> Bool) -> Eq (SchemaF a)
forall a. Eq a => SchemaF a -> SchemaF a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaF a -> SchemaF a -> Bool
$c/= :: forall a. Eq a => SchemaF a -> SchemaF a -> Bool
== :: SchemaF a -> SchemaF a -> Bool
$c== :: forall a. Eq a => SchemaF a -> SchemaF a -> Bool
Eq, (forall x. SchemaF a -> Rep (SchemaF a) x)
-> (forall x. Rep (SchemaF a) x -> SchemaF a)
-> Generic (SchemaF a)
forall x. Rep (SchemaF a) x -> SchemaF a
forall x. SchemaF a -> Rep (SchemaF a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (SchemaF a) x -> SchemaF a
forall a x. SchemaF a -> Rep (SchemaF a) x
$cto :: forall a x. Rep (SchemaF a) x -> SchemaF a
$cfrom :: forall a x. SchemaF a -> Rep (SchemaF a) x
Generic, (forall a. SchemaF a -> Rep1 SchemaF a)
-> (forall a. Rep1 SchemaF a -> SchemaF a) -> Generic1 SchemaF
forall a. Rep1 SchemaF a -> SchemaF a
forall a. SchemaF a -> Rep1 SchemaF a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 SchemaF a -> SchemaF a
$cfrom1 :: forall a. SchemaF a -> Rep1 SchemaF a
Generic1, a -> SchemaF b -> SchemaF a
(a -> b) -> SchemaF a -> SchemaF b
(forall a b. (a -> b) -> SchemaF a -> SchemaF b)
-> (forall a b. a -> SchemaF b -> SchemaF a) -> Functor SchemaF
forall a b. a -> SchemaF b -> SchemaF a
forall a b. (a -> b) -> SchemaF a -> SchemaF b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> SchemaF b -> SchemaF a
$c<$ :: forall a b. a -> SchemaF b -> SchemaF a
fmap :: (a -> b) -> SchemaF a -> SchemaF b
$cfmap :: forall a b. (a -> b) -> SchemaF a -> SchemaF b
Functor, SchemaF a -> Bool
(a -> m) -> SchemaF a -> m
(a -> b -> b) -> b -> SchemaF a -> b
(forall m. Monoid m => SchemaF m -> m)
-> (forall m a. Monoid m => (a -> m) -> SchemaF a -> m)
-> (forall m a. Monoid m => (a -> m) -> SchemaF a -> m)
-> (forall a b. (a -> b -> b) -> b -> SchemaF a -> b)
-> (forall a b. (a -> b -> b) -> b -> SchemaF a -> b)
-> (forall b a. (b -> a -> b) -> b -> SchemaF a -> b)
-> (forall b a. (b -> a -> b) -> b -> SchemaF a -> b)
-> (forall a. (a -> a -> a) -> SchemaF a -> a)
-> (forall a. (a -> a -> a) -> SchemaF a -> a)
-> (forall a. SchemaF a -> [a])
-> (forall a. SchemaF a -> Bool)
-> (forall a. SchemaF a -> Int)
-> (forall a. Eq a => a -> SchemaF a -> Bool)
-> (forall a. Ord a => SchemaF a -> a)
-> (forall a. Ord a => SchemaF a -> a)
-> (forall a. Num a => SchemaF a -> a)
-> (forall a. Num a => SchemaF a -> a)
-> Foldable SchemaF
forall a. Eq a => a -> SchemaF a -> Bool
forall a. Num a => SchemaF a -> a
forall a. Ord a => SchemaF a -> a
forall m. Monoid m => SchemaF m -> m
forall a. SchemaF a -> Bool
forall a. SchemaF a -> Int
forall a. SchemaF a -> [a]
forall a. (a -> a -> a) -> SchemaF a -> a
forall m a. Monoid m => (a -> m) -> SchemaF a -> m
forall b a. (b -> a -> b) -> b -> SchemaF a -> b
forall a b. (a -> b -> b) -> b -> SchemaF a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: SchemaF a -> a
$cproduct :: forall a. Num a => SchemaF a -> a
sum :: SchemaF a -> a
$csum :: forall a. Num a => SchemaF a -> a
minimum :: SchemaF a -> a
$cminimum :: forall a. Ord a => SchemaF a -> a
maximum :: SchemaF a -> a
$cmaximum :: forall a. Ord a => SchemaF a -> a
elem :: a -> SchemaF a -> Bool
$celem :: forall a. Eq a => a -> SchemaF a -> Bool
length :: SchemaF a -> Int
$clength :: forall a. SchemaF a -> Int
null :: SchemaF a -> Bool
$cnull :: forall a. SchemaF a -> Bool
toList :: SchemaF a -> [a]
$ctoList :: forall a. SchemaF a -> [a]
foldl1 :: (a -> a -> a) -> SchemaF a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> SchemaF a -> a
foldr1 :: (a -> a -> a) -> SchemaF a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> SchemaF a -> a
foldl' :: (b -> a -> b) -> b -> SchemaF a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> SchemaF a -> b
foldl :: (b -> a -> b) -> b -> SchemaF a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> SchemaF a -> b
foldr' :: (a -> b -> b) -> b -> SchemaF a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> SchemaF a -> b
foldr :: (a -> b -> b) -> b -> SchemaF a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> SchemaF a -> b
foldMap' :: (a -> m) -> SchemaF a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> SchemaF a -> m
foldMap :: (a -> m) -> SchemaF a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> SchemaF a -> m
fold :: SchemaF m -> m
$cfold :: forall m. Monoid m => SchemaF m -> m
Foldable, Functor SchemaF
Foldable SchemaF
Functor SchemaF
-> Foldable SchemaF
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> SchemaF a -> f (SchemaF b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    SchemaF (f a) -> f (SchemaF a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> SchemaF a -> m (SchemaF b))
-> (forall (m :: * -> *) a.
    Monad m =>
    SchemaF (m a) -> m (SchemaF a))
-> Traversable SchemaF
(a -> f b) -> SchemaF a -> f (SchemaF b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => SchemaF (m a) -> m (SchemaF a)
forall (f :: * -> *) a.
Applicative f =>
SchemaF (f a) -> f (SchemaF a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> SchemaF a -> m (SchemaF b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> SchemaF a -> f (SchemaF b)
sequence :: SchemaF (m a) -> m (SchemaF a)
$csequence :: forall (m :: * -> *) a. Monad m => SchemaF (m a) -> m (SchemaF a)
mapM :: (a -> m b) -> SchemaF a -> m (SchemaF b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> SchemaF a -> m (SchemaF b)
sequenceA :: SchemaF (f a) -> f (SchemaF a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
SchemaF (f a) -> f (SchemaF a)
traverse :: (a -> f b) -> SchemaF a -> f (SchemaF b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> SchemaF a -> f (SchemaF b)
$cp2Traversable :: Foldable SchemaF
$cp1Traversable :: Functor SchemaF
Traversable)
    deriving ((Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SchemaF a -> ShowS
(Int -> a -> ShowS) -> ([a] -> ShowS) -> [SchemaF a] -> ShowS
(forall a.
 (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SchemaF a -> ShowS)
-> (forall a.
    (Int -> a -> ShowS) -> ([a] -> ShowS) -> [SchemaF a] -> ShowS)
-> Show1 SchemaF
forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SchemaF a -> ShowS
forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> [SchemaF a] -> ShowS
forall (f :: * -> *).
(forall a.
 (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS)
-> (forall a.
    (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS)
-> Show1 f
liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [SchemaF a] -> ShowS
$cliftShowList :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> [SchemaF a] -> ShowS
liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SchemaF a -> ShowS
$cliftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SchemaF a -> ShowS
Show1, ReadPrec a -> ReadPrec [a] -> ReadPrec (SchemaF a)
ReadPrec a -> ReadPrec [a] -> ReadPrec [SchemaF a]
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (SchemaF a)
(Int -> ReadS a) -> ReadS [a] -> ReadS [SchemaF a]
(forall a.
 (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (SchemaF a))
-> (forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [SchemaF a])
-> (forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (SchemaF a))
-> (forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [SchemaF a])
-> Read1 SchemaF
forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [SchemaF a]
forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (SchemaF a)
forall a. (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (SchemaF a)
forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [SchemaF a]
forall (f :: * -> *).
(forall a. (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a))
-> (forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [f a])
-> (forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (f a))
-> (forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [f a])
-> Read1 f
liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [SchemaF a]
$cliftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [SchemaF a]
liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (SchemaF a)
$cliftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (SchemaF a)
liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [SchemaF a]
$cliftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [SchemaF a]
liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (SchemaF a)
$cliftReadsPrec :: forall a. (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (SchemaF a)
Read1, (a -> b -> Bool) -> SchemaF a -> SchemaF b -> Bool
(forall a b. (a -> b -> Bool) -> SchemaF a -> SchemaF b -> Bool)
-> Eq1 SchemaF
forall a b. (a -> b -> Bool) -> SchemaF a -> SchemaF b -> Bool
forall (f :: * -> *).
(forall a b. (a -> b -> Bool) -> f a -> f b -> Bool) -> Eq1 f
liftEq :: (a -> b -> Bool) -> SchemaF a -> SchemaF b -> Bool
$cliftEq :: forall a b. (a -> b -> Bool) -> SchemaF a -> SchemaF b -> Bool
Eq1) via FunctorClassesDefault SchemaF

type Schema = Fix SchemaF

instance Semigroup Schema where
    <> :: Schema -> Schema -> Schema
(<>) = Schema -> Schema -> Schema
sumType

sumType :: Schema -> Schema -> Schema
sumType :: Schema -> Schema -> Schema
sumType (Fix (Sum Maybe DatatypeName
da [Schema]
a)) (Fix (Sum Maybe DatatypeName
db [Schema]
b)) = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ Maybe DatatypeName -> [Schema] -> SchemaF Schema
forall a. Maybe DatatypeName -> [a] -> SchemaF a
Sum (Maybe DatatypeName
da Maybe DatatypeName -> Maybe DatatypeName -> Maybe DatatypeName
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe DatatypeName
db) ([Schema]
a [Schema] -> [Schema] -> [Schema]
forall a. [a] -> [a] -> [a]
++ [Schema]
b)
sumType (Fix (Sum Maybe DatatypeName
da [Schema]
a)) Schema
b                = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ Maybe DatatypeName -> [Schema] -> SchemaF Schema
forall a. Maybe DatatypeName -> [a] -> SchemaF a
Sum Maybe DatatypeName
da ([Schema]
a [Schema] -> [Schema] -> [Schema]
forall a. [a] -> [a] -> [a]
++ [Schema
b])
sumType Schema
a (Fix (Sum Maybe DatatypeName
db [Schema]
b))                = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ Maybe DatatypeName -> [Schema] -> SchemaF Schema
forall a. Maybe DatatypeName -> [a] -> SchemaF a
Sum Maybe DatatypeName
db (Schema
a Schema -> [Schema] -> [Schema]
forall a. a -> [a] -> [a]
: [Schema]
b)
sumType Schema
a Schema
b                               = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ Maybe DatatypeName -> [Schema] -> SchemaF Schema
forall a. Maybe DatatypeName -> [a] -> SchemaF a
Sum Maybe DatatypeName
forall a. Maybe a
Nothing [Schema
a, Schema
b]

prodType :: Schema -> Schema -> Schema
prodType :: Schema -> Schema -> Schema
prodType (Fix (Prod [Schema]
a)) (Fix (Prod [Schema]
b)) = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ [Schema] -> SchemaF Schema
forall a. [a] -> SchemaF a
Prod ([Schema]
a [Schema] -> [Schema] -> [Schema]
forall a. [a] -> [a] -> [a]
++ [Schema]
b)
prodType (Fix (Prod [Schema]
a)) Schema
b              = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ [Schema] -> SchemaF Schema
forall a. [a] -> SchemaF a
Prod ([Schema]
a [Schema] -> [Schema] -> [Schema]
forall a. [a] -> [a] -> [a]
++ [Schema
b])
prodType Schema
a (Fix (Prod [Schema]
b))              = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ [Schema] -> SchemaF Schema
forall a. [a] -> SchemaF a
Prod (Schema
a Schema -> [Schema] -> [Schema]
forall a. a -> [a] -> [a]
: [Schema]
b)
prodType Schema
a Schema
b                           = SchemaF Schema -> Schema
forall (f :: * -> *). f (Fix f) -> Fix f
Fix (SchemaF Schema -> Schema) -> SchemaF Schema -> Schema
forall a b. (a -> b) -> a -> b
$ [Schema] -> SchemaF Schema
forall a. [a] -> SchemaF a
Prod [Schema
a, Schema
b]