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 |
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, Maybe Expr, Maybe [[Expr]], [String], Bool, Expr)
- type Reification = [Reification1] -> [Reification1]
- class (Typeable a, Name a) => Conjurable a where
- conjureArgumentHoles :: a -> [Expr]
- conjureEquality :: a -> Maybe Expr
- conjureTiers :: a -> Maybe [[Expr]]
- conjureSubTypes :: a -> Reification
- conjureIf :: a -> Expr
- conjureCases :: a -> [Expr]
- conjureArgumentCases :: a -> [[Expr]]
- conjureSize :: a -> Int
- conjureExpress :: a -> Expr -> Expr
- conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe a
- conjureType :: Conjurable a => a -> Reification
- reifyTiers :: (Listable a, Show a, Typeable a) => a -> Maybe [[Expr]]
- reifyEquality :: (Eq a, Typeable a) => a -> Maybe Expr
- reifyExpress :: (Express a, Show a) => a -> Expr -> Expr
- conjureApplication :: Conjurable f => String -> f -> Expr
- conjureVarApplication :: Conjurable f => String -> f -> Expr
- conjurePats :: Conjurable f => [Expr] -> String -> f -> [[[Expr]]]
- conjureHoles :: 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
- conjureIsDeconstructor :: Conjurable f => f -> Int -> Expr -> Bool
- conjureIsUnbreakable :: Conjurable f => f -> Expr -> Bool
- conjureReification :: Conjurable a => a -> [Reification1]
- conjureReification1 :: Conjurable a => a -> Reification1
- cevaluate :: Conjurable f => Int -> Defn -> Maybe f
- ceval :: Conjurable f => Int -> f -> Defn -> f
- cevl :: Conjurable f => Int -> Defn -> f
Documentation
type Reification1 = (Expr, Maybe Expr, Maybe [[Expr]], [String], Bool, Expr) Source #
Single reification of some functions over a type as Expr
s.
A hole, 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, Name a) => Conjurable a where Source #
Class of Conjurable
types.
Functions are Conjurable
if all their arguments are Conjurable
, Listable
and Show
able.
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 ...) = x
Above 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
)
conjureArgumentHoles :: a -> [Expr] Source #
conjureEquality :: a -> Maybe Expr Source #
conjureTiers :: a -> Maybe [[Expr]] Source #
conjureSubTypes :: a -> Reification Source #
conjureIf :: a -> Expr Source #
conjureCases :: a -> [Expr] Source #
conjureArgumentCases :: a -> [[Expr]] Source #
conjureSize :: a -> Int Source #
conjureExpress :: a -> Expr -> Expr Source #
conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe a 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 #
conjurePats :: Conjurable f => [Expr] -> String -> f -> [[[Expr]]] Source #
conjureHoles :: 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 toRational :: A -> Rational # | |
Show A | |
Ix A | |
Express A Source # | |
Defined in Conjure.Expr | |
Name A Source # | |
Defined in Conjure.Conjurable | |
Listable A | |
Conjurable A Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: A -> [Expr] Source # conjureEquality :: A -> Maybe Expr Source # conjureTiers :: A -> Maybe [[Expr]] Source # conjureSubTypes :: A -> Reification Source # conjureIf :: A -> Expr Source # conjureCases :: A -> [Expr] Source # conjureArgumentCases :: A -> [[Expr]] Source # conjureSize :: A -> Int Source # conjureExpress :: A -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe A 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 toRational :: B -> Rational # | |
Show B | |
Ix B | |
Express B Source # | |
Defined in Conjure.Expr | |
Name B Source # | |
Defined in Conjure.Conjurable | |
Listable B | |
Conjurable B Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: B -> [Expr] Source # conjureEquality :: B -> Maybe Expr Source # conjureTiers :: B -> Maybe [[Expr]] Source # conjureSubTypes :: B -> Reification Source # conjureIf :: B -> Expr Source # conjureCases :: B -> [Expr] Source # conjureArgumentCases :: B -> [[Expr]] Source # conjureSize :: B -> Int Source # conjureExpress :: B -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe B 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 toRational :: C -> Rational # | |
Show C | |
Ix C | |
Express C Source # | |
Defined in Conjure.Expr | |
Name C Source # | |
Defined in Conjure.Conjurable | |
Listable C | |
Conjurable C Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: C -> [Expr] Source # conjureEquality :: C -> Maybe Expr Source # conjureTiers :: C -> Maybe [[Expr]] Source # conjureSubTypes :: C -> Reification Source # conjureIf :: C -> Expr Source # conjureCases :: C -> [Expr] Source # conjureArgumentCases :: C -> [[Expr]] Source # conjureSize :: C -> Int Source # conjureExpress :: C -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe C 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 toRational :: D -> Rational # | |
Show D | |
Ix D | |
Express D Source # | |
Defined in Conjure.Expr | |
Name D Source # | |
Defined in Conjure.Conjurable | |
Listable D | |
Conjurable D Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: D -> [Expr] Source # conjureEquality :: D -> Maybe Expr Source # conjureTiers :: D -> Maybe [[Expr]] Source # conjureSubTypes :: D -> Reification Source # conjureIf :: D -> Expr Source # conjureCases :: D -> [Expr] Source # conjureArgumentCases :: D -> [[Expr]] Source # conjureSize :: D -> Int Source # conjureExpress :: D -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe D 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 toRational :: E -> Rational # | |
Show E | |
Ix E | |
Express E Source # | |
Defined in Conjure.Expr | |
Name E Source # | |
Defined in Conjure.Conjurable | |
Listable E | |
Conjurable E Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: E -> [Expr] Source # conjureEquality :: E -> Maybe Expr Source # conjureTiers :: E -> Maybe [[Expr]] Source # conjureSubTypes :: E -> Reification Source # conjureIf :: E -> Expr Source # conjureCases :: E -> [Expr] Source # conjureArgumentCases :: E -> [[Expr]] Source # conjureSize :: E -> Int Source # conjureExpress :: E -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe E 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 toRational :: F -> Rational # | |
Show F | |
Ix F | |
Express F Source # | |
Defined in Conjure.Expr | |
Name F Source # | |
Defined in Conjure.Conjurable | |
Listable F | |
Conjurable F Source # | |
Defined in Conjure.Conjurable conjureArgumentHoles :: F -> [Expr] Source # conjureEquality :: F -> Maybe Expr Source # conjureTiers :: F -> Maybe [[Expr]] Source # conjureSubTypes :: F -> Reification Source # conjureIf :: F -> Expr Source # conjureCases :: F -> [Expr] Source # conjureArgumentCases :: F -> [[Expr]] Source # conjureSize :: F -> Int Source # conjureExpress :: F -> Expr -> Expr Source # conjureEvaluate :: (Expr -> Expr) -> Int -> Defn -> Expr -> Maybe F Source # |
conjureIsDeconstructor :: Conjurable f => f -> Int -> Expr -> Bool Source #
conjureIsUnbreakable :: Conjurable f => f -> Expr -> Bool Source #
conjureReification :: Conjurable a => a -> [Reification1] Source #
conjureReification1 :: Conjurable a => a -> Reification1 Source #