Safe Haskell | None |
---|---|
Language | Haskell2010 |
TypeMachine.Functions
Synopsis
- pick :: [String] -> Type -> TM Type
- omit :: [String] -> Type -> TM Type
- record :: [String] -> Q Type -> TM Type
- intersection :: Type -> Type -> TM Type
- intersection' :: Type -> Type -> TM Type
- union :: Type -> Type -> TM Type
- union' :: Type -> Type -> TM Type
- require :: [String] -> Type -> TM Type
- partial :: Type -> TM Type
- partial' :: Type -> TM Type
- apply :: Q Type -> Type -> TM Type
- applyMany :: [Q Type] -> Type -> TM Type
- intersectionWithSelector :: (String -> Selector) -> Type -> Type -> TM Type
- unionWithSelector :: (String -> Selector) -> Type -> Type -> TM Type
- data Selector
- keysOf :: Type -> TM [String]
Fields
Record
record :: [String] -> Q Type -> TM Type Source #
Creates a type from a list of keys and a ToFieldType
Issues a log if some keys are duplicated
> record ["a", "b"] [t|Int|] data _ = { a :: Int, b :: Int }
Union and Intersection
Optional
require :: [String] -> Type -> TM Type Source #
Mark fields are required
> data A = A { a :: Maybe Int, b :: Int } > require ["a"]<:>
toType
''A data _ = { a :: Int, b :: Int }
Type Parameters
With Selector
intersectionWithSelector :: (String -> Selector) -> Type -> Type -> TM Type Source #
Variant of intersection
where user can decide which value to keep (the left object's or the right's) in case of overlap
unionWithSelector :: (String -> Selector) -> Type -> Type -> TM Type Source #
Variant of union
where user can decide which value to keep (the left object's or the right's) in case of overlap
Selector for functions like intersectionWithSelector