| Copyright | (c) 2021 Rudy Matela |
|---|---|
| License | 3-Clause BSD (see the file LICENSE) |
| Maintainer | Rudy Matela <rudy@matela.com.br> |
| Safe Haskell | None |
| Language | Haskell2010 |
Conjure.Conjurable
Description
This module is part of Conjure.
This defines the Conjurable typeclass
and utilities involving it.
You are probably better off importing Conjure.
Synopsis
- type Reification1 = (Expr, Expr, Maybe Expr, Maybe [[Expr]])
- type Reification = [Reification1] -> [Reification1]
- class Typeable a => Conjurable a where
- conjureArgumentHoles :: a -> [Expr]
- conjureEquality :: a -> Maybe Expr
- conjureTiers :: a -> Maybe [[Expr]]
- conjureSubTypes :: a -> Reification
- conjureType :: Conjurable a => a -> Reification
- reifyTiers :: (Listable a, Show a, Typeable a) => a -> Maybe [[Expr]]
- reifyEquality :: (Eq a, Typeable a) => a -> Maybe Expr
- conjureApplication :: Conjurable f => String -> f -> Expr
- conjureVarApplication :: Conjurable f => String -> f -> Expr
- conjureHoles :: Conjurable f => f -> [Expr]
- conjureIfs :: Conjurable f => f -> [Expr]
- conjureTiersFor :: Conjurable f => f -> Expr -> [[Expr]]
- conjureAreEqual :: Conjurable f => f -> Int -> Expr -> Expr -> Bool
- conjureMkEquation :: Conjurable f => f -> Expr -> Expr -> Expr
- data A
- data B
- data C
- data D
- data E
- data F
Documentation
type Reification1 = (Expr, Expr, Maybe Expr, Maybe [[Expr]]) Source #
Single reification of some functions over a type as Exprs.
A hole, an if function, an equality function and tiers.
type Reification = [Reification1] -> [Reification1] Source #
A reification over a collection of types.
Represented as a transformation of a list to a list.
class Typeable a => Conjurable a where Source #
Class of Conjurable types.
Functions are Conjurable
if all their arguments are Conjurable, Listable and Showable.
For atomic types that are Listable,
instances are defined as:
instance Conjurable Atomic where conjureTiers = reifyTiers
For atomic types that are both Listable and Eq,
instances are defined as:
instance Conjurable Atomic where conjureTiers = reifyTiers conjureEquality = reifyEquality
For types with subtypes, instances are defined as:
instance Conjurable Composite where
conjureTiers = reifyTiers
conjureEquality = reifyEquality
conjureSubTypes x = conjureType y
. conjureType z
. conjureType w
where
(Composite ... y ... z ... w ...) = xAbove x, y, z and w are just proxies.
The Proxy type was avoided for backwards compatibility.
Please see the source code of Conjure.Conjurable for more examples.
(cf. reifyTiers, reifyEquality, conjureType)
Minimal complete definition
Nothing
Methods
conjureArgumentHoles :: a -> [Expr] Source #
conjureEquality :: a -> Maybe Expr Source #
conjureTiers :: a -> Maybe [[Expr]] Source #
conjureSubTypes :: a -> Reification Source #
Instances
conjureType :: Conjurable a => a -> Reification Source #
reifyTiers :: (Listable a, Show a, Typeable a) => a -> Maybe [[Expr]] Source #
Reifies equality to be used in a conjurable type.
This is to be used
in the definition of conjureTiers
of Conjurable typeclass instances:
instance ... => Conjurable <Type> where ... conjureTiers = reifyTiers ...
reifyEquality :: (Eq a, Typeable a) => a -> Maybe Expr Source #
Reifies equality to be used in a conjurable type.
This is to be used
in the definition of conjureEquality
of Conjurable typeclass instances:
instance ... => Conjurable <Type> where ... conjureEquality = reifyEquality ...
conjureApplication :: Conjurable f => String -> f -> Expr Source #
conjureVarApplication :: Conjurable f => String -> f -> Expr Source #
conjureHoles :: Conjurable f => f -> [Expr] Source #
conjureIfs :: Conjurable f => f -> [Expr] Source #
conjureTiersFor :: Conjurable f => f -> Expr -> [[Expr]] Source #
conjureAreEqual :: Conjurable f => f -> Int -> Expr -> Expr -> Bool Source #
conjureMkEquation :: Conjurable f => f -> Expr -> Expr -> Expr Source #
Generic type A.
Can be used to test polymorphic functions with a type variable
such as take or sort:
take :: Int -> [a] -> [a] sort :: Ord a => [a] -> [a]
by binding them to the following types:
take :: Int -> [A] -> [A] sort :: [A] -> [A]
This type is homomorphic to Nat6, B, C, D, E and F.
It is instance to several typeclasses so that it can be used to test functions with type contexts.
Instances
| Bounded A | |
| Enum A | |
| Eq A | |
| Integral A | |
| Num A | |
| Ord A | |
| Read A | |
| Real A | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: A -> Rational # | |
| Show A | |
| Ix A | |
| Listable A | |
| Conjurable A Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: A -> [Expr] Source # conjureEquality :: A -> Maybe Expr Source # conjureTiers :: A -> Maybe [[Expr]] Source # conjureSubTypes :: A -> Reification Source # | |
Generic type B.
Can be used to test polymorphic functions with two type variables
such as map or foldr:
map :: (a -> b) -> [a] -> [b] foldr :: (a -> b -> b) -> b -> [a] -> b
by binding them to the following types:
map :: (A -> B) -> [A] -> [B] foldr :: (A -> B -> B) -> B -> [A] -> B
Instances
| Bounded B | |
| Enum B | |
| Eq B | |
| Integral B | |
| Num B | |
| Ord B | |
| Read B | |
| Real B | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: B -> Rational # | |
| Show B | |
| Ix B | |
| Listable B | |
| Conjurable B Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: B -> [Expr] Source # conjureEquality :: B -> Maybe Expr Source # conjureTiers :: B -> Maybe [[Expr]] Source # conjureSubTypes :: B -> Reification Source # | |
Generic type C.
Can be used to test polymorphic functions with three type variables
such as uncurry or zipWith:
uncurry :: (a -> b -> c) -> (a, b) -> c zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
by binding them to the following types:
uncurry :: (A -> B -> C) -> (A, B) -> C zipWith :: (A -> B -> C) -> [A] -> [B] -> [C]
Instances
| Bounded C | |
| Enum C | |
| Eq C | |
| Integral C | |
| Num C | |
| Ord C | |
| Read C | |
| Real C | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: C -> Rational # | |
| Show C | |
| Ix C | |
| Listable C | |
| Conjurable C Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: C -> [Expr] Source # conjureEquality :: C -> Maybe Expr Source # conjureTiers :: C -> Maybe [[Expr]] Source # conjureSubTypes :: C -> Reification Source # | |
Generic type D.
Can be used to test polymorphic functions with four type variables.
Instances
| Bounded D | |
| Enum D | |
| Eq D | |
| Integral D | |
| Num D | |
| Ord D | |
| Read D | |
| Real D | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: D -> Rational # | |
| Show D | |
| Ix D | |
| Listable D | |
| Conjurable D Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: D -> [Expr] Source # conjureEquality :: D -> Maybe Expr Source # conjureTiers :: D -> Maybe [[Expr]] Source # conjureSubTypes :: D -> Reification Source # | |
Generic type E.
Can be used to test polymorphic functions with five type variables.
Instances
| Bounded E | |
| Enum E | |
| Eq E | |
| Integral E | |
| Num E | |
| Ord E | |
| Read E | |
| Real E | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: E -> Rational # | |
| Show E | |
| Ix E | |
| Listable E | |
| Conjurable E Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: E -> [Expr] Source # conjureEquality :: E -> Maybe Expr Source # conjureTiers :: E -> Maybe [[Expr]] Source # conjureSubTypes :: E -> Reification Source # | |
Generic type F.
Can be used to test polymorphic functions with five type variables.
Instances
| Bounded F | |
| Enum F | |
| Eq F | |
| Integral F | |
| Num F | |
| Ord F | |
| Read F | |
| Real F | |
Defined in Test.LeanCheck.Utils.Types Methods toRational :: F -> Rational # | |
| Show F | |
| Ix F | |
| Listable F | |
| Conjurable F Source # | |
Defined in Conjure.Conjurable Methods conjureArgumentHoles :: F -> [Expr] Source # conjureEquality :: F -> Maybe Expr Source # conjureTiers :: F -> Maybe [[Expr]] Source # conjureSubTypes :: F -> Reification Source # | |