hschema-0.0.1.1: Describe schemas for your Haskell data types.

Safe HaskellNone
LanguageHaskell2010

Data.Schema

Synopsis

Documentation

data Field s o a Source #

The type of a field of type a, belonging to the data type o and based on schema s

Instances
Profunctor (Field s) Source # 
Instance details

Defined in Data.Schema.Internal.Types

Methods

dimap :: (a -> b) -> (c -> d) -> Field s b c -> Field s a d #

lmap :: (a -> b) -> Field s b c -> Field s a c #

rmap :: (b -> c) -> Field s a b -> Field s a c #

(#.) :: Coercible c b => q b c -> Field s a b -> Field s a c #

(.#) :: Coercible b a => Field s b c -> q a b -> Field s a c #

Functor (Field s o) Source # 
Instance details

Defined in Data.Schema.Internal.Types

Methods

fmap :: (a -> b) -> Field s o a -> Field s o b #

(<$) :: a -> Field s o b -> Field s o a #

Applicative (Field s o) Source # 
Instance details

Defined in Data.Schema.Internal.Types

Methods

pure :: a -> Field s o a #

(<*>) :: Field s o (a -> b) -> Field s o a -> Field s o b #

liftA2 :: (a -> b -> c) -> Field s o a -> Field s o b -> Field s o c #

(*>) :: Field s o a -> Field s o b -> Field s o b #

(<*) :: Field s o a -> Field s o b -> Field s o a #

type Fields s o = Field s o o Source #

The set of fields for the data type o based on schema s

field :: Text -> s a -> Getter o a -> Field s o a Source #

Define a field

optional :: Text -> s a -> Getter o (Maybe a) -> Field s o (Maybe a) Source #

alt :: Text -> s b -> Prism' a b -> AltDef s a Source #

Define an alternative

data Schema p a Source #

The Schema type itself for a set of primitives p

Instances
HFunctor Schema Source #

An Schema has a HFunctor that performs a natural transformation of the primitive algebra of the Schema

Instance details

Defined in Data.Schema.Internal.Types

Methods

hfmap :: (m ~> n) -> Schema m ~> Schema n Source #

Invariant (Schema p) Source # 
Instance details

Defined in Data.Schema.Internal.Types

Methods

invmap :: (a -> b) -> (b -> a) -> Schema p a -> Schema p b #

class HasSchema a where Source #

Associated Types

type PrimitivesOf a :: * -> * Source #

prim :: p a -> Schema p a Source #

Define an annotated schema for primitives of type p

const :: a -> Schema p a Source #

Define a schema for a type that is always constant

record :: Fields (Schema p) a -> Schema p a Source #

Define the schema of record using the given fields

asList :: Iso' (Vector a) [a] Source #

Define the schema of a list based on the element type

toList :: Schema p (Vector a) -> Schema p [a] Source #

oneOf :: [AltDef (Schema p) a] -> Schema p a Source #

Define the schema of an union (coproduct) type based on the given alternatives

alias :: Iso' a b -> Schema p a -> Schema p b Source #

Define an schema alias that is isomorphic to another one using the given ISO transformation