refined-subtype-0.1.0.0: compute subtypes from refinement types
MaintainerOlaf Klinke
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Type.Predicate

Description

This module defines the GADT Predicate and the category of predicate transformers.

Synopsis

Predicates on polynomial types

data Predicate :: (Type -> Type) -> Type where Source #

Predicates on Generic representations of polynomial types. The only way to evaluate predicates on unions is to do Case analysis. All predicates on products must eventually extract the first or second component.

Constructors

Wildcard 

Fields

Neg 

Fields

(:\/) 

Fields

(:/\) 

Fields

Fst :: Predicate f -> Predicate (f :*: g) 
Snd :: Predicate g -> Predicate (f :*: g) 
Case :: Predicate f -> Predicate g -> Predicate (f :+: g) 
RecP :: Predicate f -> Predicate (Rec1 f) 
MetaP :: Predicate f -> Predicate (M1 i m f) 
ConstP :: (Generic c, Rep c ~ f) => Predicate f -> Predicate (K1 i c) 

eval :: Predicate ty -> ty p -> Bool Source #

evaluate a predicate

Predicate transformers

insL :: Predicate (f :+: g) -> Predicate f Source #

insL witnesses the inclusion of f into f :+: g. Stone dual of Left.

insR :: Predicate (f :+: g) -> Predicate g Source #

insR witnesses the inclusion of g into f :+: g. Stone dual of Right.

first :: (Predicate f -> Predicate g) -> Predicate (f :*: h) -> Predicate (g :*: h) Source #

Stone dual of Control.Arrow.first

second :: (Predicate f -> Predicate g) -> Predicate (h :*: f) -> Predicate (h :*: g) Source #

Stone dual of Control.Arrow.second

mapRec :: Predicate (Rec1 f) -> Predicate f Source #

inverse to RecP

mapMeta :: Predicate (M1 i m f) -> Predicate f Source #

inverse to MetaP

mapConst :: Generic c => Predicate (K1 i c) -> Predicate (Rep c) Source #

inverse to ConstP

newtype GStone f g Source #

Predicate transformers form a cartesian category. We can regard an element of GStone (Rep x) (Rep y) as the Stone dual of a function x -> y. Instead of the pair (,) in this category :*: plays the role of the cartesian product.

Constructors

GStone (Predicate g -> Predicate f) 

Instances

Instances details
Category GStone Source # 
Instance details

Defined in Data.Type.Predicate

Methods

id :: forall (a :: k). GStone a a #

(.) :: forall (b :: k) (c :: k) (a :: k). GStone b c -> GStone a b -> GStone a c #

gDomain :: forall f g. Typeable (f ()) => GStone f g -> SomeTypeRep Source #

The monomorphic type representation of the domain f of the morphism, instantiated at parameter ().

universal properties

universalProd :: (Predicate a -> Predicate z) -> (Predicate b -> Predicate z) -> Predicate (a :*: b) -> Predicate z Source #

universal property of the product :*: and Stone dual of (Control.Arrow.&&&). Notice that Fst and Snd are the Stone duals of fst and snd, respectively. Accordingly, universalProd Fst Snd is the identity.

universalUnion :: (Predicate z -> Predicate a) -> (Predicate z -> Predicate b) -> Predicate z -> Predicate (a :+: b) Source #

universal property of the union :+: