Copyright | (c) Justin Le 2018 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Data.Type.Predicate.Param
Synopsis
- type ParamPred k v = k -> Predicate v
- type IsTC (t :: v -> k) = EqBy (TyCon1 t)
- data EqBy (a :: v ~> k) (b :: k) (c :: TyFun v Type)
- data FlipPP (a :: ParamPred v k) (b :: k) (c :: TyFun v Type)
- data ConstPP (a :: Predicate v) (b :: k) (c :: TyFun v Type)
- data PPMap (a :: k ~> j) (b :: ParamPred j v) (c :: k) (d :: TyFun v Type)
- data PPMapV (a :: u ~> v) (b :: ParamPred k u) (c :: k) (d :: TyFun v Type)
- type InP (f :: Type -> Type) = ElemSym1 f :: f k -> TyFun k Type -> Type
- data AnyMatch (f :: Type -> Type) (a :: ParamPred k v) (b :: f k) (c :: TyFun v Type)
- data TyPP (a :: k -> v -> Type) (b :: k) (c :: TyFun v Type)
- data Found (a :: ParamPred k v) (b :: TyFun k Type)
- type NotFound (p :: ParamPred k v) = Not (Found p)
- type Selectable (p :: ParamPred k1 v) = Provable (Found p)
- select :: forall {k1} {v} (p :: ParamPred k1 v). Selectable p => Prove (Found p)
- type Searchable (p :: ParamPred k1 v) = Decidable (Found p)
- search :: forall {k1} {v} (p :: ParamPred k1 v). Searchable p => Decide (Found p)
- inPNotNull :: forall {v} (f :: Type -> Type) (a :: f v). Sing a -> (Found (InP f :: ParamPred (f v) v) @@ a) -> (NotNull f :: Predicate (f v)) @@ a
- notNullInP :: forall {k} (f :: Type -> Type) (a :: f k). Sing a -> ((NotNull f :: Predicate (f k)) @@ a) -> Found (InP f :: ParamPred (f k) k) @@ a
- type SelectableTC (t :: k1 -> v -> Type) = Provable (Found (TyPP t))
- selectTC :: forall {k1} {v} (t :: k1 -> v -> Type). SelectableTC t => Prove (Found (TyPP t))
- type SearchableTC (t :: k1 -> v -> Type) = Decidable (Found (TyPP t))
- searchTC :: forall {k1} {v} (t :: k1 -> v -> Type). SearchableTC t => Decide (Found (TyPP t))
- data OrP (a :: ParamPred k v) (b :: ParamPred k v) (c :: k) (d :: TyFun v Type)
- data AndP (a :: ParamPred k v) (b :: ParamPred k u) (c :: k) (d :: TyFun (v, u) Type)
Parameterized Predicates
type ParamPred k v = k -> Predicate v Source #
A parameterized predicate. See Found
for more information.
type IsTC (t :: v -> k) = EqBy (TyCon1 t) Source #
Found (
is true if IsTC
t) @@ xx
was made using the unary type
constructor t
.
For example:
type IsJust = (Found (IsTC 'Just) :: Predicate (Maybe v))
makes a predicate where IsJust @@ x
is true if x
is Just
, and
false if x
is Nothing
.
For a more general version, see EqBy
The kind of IsTC
is:
IsTC
:: (v -> k) ->ParamPred
k vFound
(IsTC
t) ::Predicate
k
Applied to specific things:
IsTC
'Just
::ParamPred
(Maybe v) vFound
(IsTC
'Just'
) ::Predicate
(Maybe v)
Since: 0.1.5.0
data EqBy (a :: v ~> k) (b :: k) (c :: TyFun v Type) Source #
data FlipPP (a :: ParamPred v k) (b :: k) (c :: TyFun v Type) Source #
Flip the arguments of a ParamPred
.
data PPMap (a :: k ~> j) (b :: ParamPred j v) (c :: k) (d :: TyFun v Type) Source #
Pre-compose a function to a ParamPred
. Is essentially
, but unfortunately defunctionalization doesn't work too well with
that definition.flip
(.
)
Instances
(Decidable (Found p), SingI f) => Decidable (Found (PPMap f p) :: TyFun k Type -> Type) Source # | |
(Provable (Found p), SingI f) => Provable (Found (PPMap f p) :: TyFun k Type -> Type) Source # | |
Auto (Found p) (f @@ a) => Auto (Found (PPMap f p) :: TyFun k Type -> Type) (a :: k) Source # | Since: 0.1.2.0 |
Auto (NotFound p) (f @@ a) => Auto (NotFound (PPMap f p) :: Predicate k) (a :: k) Source # | Since: 0.1.2.0 |
type Apply (PPMap f p x :: TyFun k4 Type -> Type) (y :: k4) Source # | |
data PPMapV (a :: u ~> v) (b :: ParamPred k u) (c :: k) (d :: TyFun v Type) Source #
Pre-compose a function to a ParamPred
, but on the "value" side.
Since: 0.1.5.0
data AnyMatch (f :: Type -> Type) (a :: ParamPred k v) (b :: f k) (c :: TyFun v Type) Source #
takes a parmaeterized predicate on AnyMatch
fk
(testing for
a v
) and turns it into a parameterized predicate on f k
(testing for
a v
). It "lifts" the domain into f
.
An
is a predicate taking an argument AnyMatch
f p asa
and
testing if p a ::
is satisfied for any item in Predicate
kas ::
f k
.
A
tests if a ParamPred
k vk
can create some v
. The resulting
tests if any ParamPred
(f k) vk
in f k
can create some v
.
Instances
(SingI as, AutoAll f (Not (Found p)) as) => Auto (Not (Found (AnyMatch f p)) :: TyFun (f k) Type -> Type) (as :: f k) Source # | Since: 0.1.2.0 |
(Universe f, Decidable (Found p)) => Decidable (Found (AnyMatch f p) :: TyFun (f k) Type -> Type) Source # | |
type Apply (AnyMatch f p as :: TyFun k2 Type -> Type) (a :: k2) Source # | |
data TyPP (a :: k -> v -> Type) (b :: k) (c :: TyFun v Type) Source #
Deciding and Proving
data Found (a :: ParamPred k v) (b :: TyFun k Type) Source #
Convert a parameterized predicate into a predicate on the parameter.
A
is a predicate on Found
pp ::
that tests a ParamPred
k vk
for the fact that there exists a v
where
is satisfied.ParamPred
k v
Intended as the basic interface for ParamPred
, since it turns
a ParamPred
into a normal Predicate
, which can have Decidable
and
Provable
instances.
For some context, an instance of
, where Provable
(Found
P)P ::
, means that for any input ParamPred
k vx :: k
, we can always find
a y :: v
such that we have P x @@ y
.
In the language of quantifiers, it means that forall x :: k
, there
exists a y :: v
such that P x @@ y
.
For an instance of
, it means that for all Decidable
(Found
P)x
:: k
, we can prove or disprove the fact that there exists a y :: v
such that P x @@ y
.
Instances
type NotFound (p :: ParamPred k v) = Not (Found p) Source #
Convert a parameterized predicate into a predicate on the parameter.
A
is a predicate on Found
pp ::
that tests a ParamPred
k vk
for the fact that there cannot exist a v
where
is
satisfied. That is, ParamPred
k v
is satisfied if no NotFound
P @@ xy :: v
can exist where P x @@ y
is satisfied.
For some context, an instance of
, where Provable
(NotFound
P)P
::
, means that for any input ParamPred
k vx :: k
, we can always
reject any y :: v
that claims to satisfy P x @@ y
.
In the language of quantifiers, it means that forall x :: k
, there
does not exist a y :: v
such that P x @@ y
.
For an instance of
, it means that for all Decidable
(Found
P)x
:: k
, we can prove or disprove the fact that there does not exist a y
:: v
such that P x @@ y
.
Since: 0.1.2.0
type Selectable (p :: ParamPred k1 v) = Provable (Found p) Source #
A constraint that a
s "selectable". It means that
for any input ParamPred
k vx :: k
, we can always find a y :: v
that satisfies P
x @@ y
. We can "select" that y
, no matter what.
select :: forall {k1} {v} (p :: ParamPred k1 v). Selectable p => Prove (Found p) Source #
The proving/selecting function for
.Selectable
p
Because this is ambiguously typed, it must be called by applying the
ParamPred
:
select
@p
See selectTC
and SelectableTC
for a version that isn't ambiguously
typed, but only works when p
is a type constructor.
type Searchable (p :: ParamPred k1 v) = Decidable (Found p) Source #
A constraint that a
is "searchable". It means that
for any input ParamPred
k vx :: k
, we can prove or disprove that there exists a y
:: v
that satisfies P x @@ y
. We can "search" for that y
, and
prove that it can or cannot be found.
search :: forall {k1} {v} (p :: ParamPred k1 v). Searchable p => Decide (Found p) Source #
The deciding/searching function for
.Searchable
p
Because this is ambiguously typed, it must be called by applying the
ParamPred
:
search
@p
See searchTC
and SearchableTC
for a version that isn't ambiguously
typed, but only works when p
is a type constructor.
inPNotNull :: forall {v} (f :: Type -> Type) (a :: f v). Sing a -> (Found (InP f :: ParamPred (f v) v) @@ a) -> (NotNull f :: Predicate (f v)) @@ a Source #
notNullInP :: forall {k} (f :: Type -> Type) (a :: f k). Sing a -> ((NotNull f :: Predicate (f k)) @@ a) -> Found (InP f :: ParamPred (f k) k) @@ a Source #
Type Constructors
type SelectableTC (t :: k1 -> v -> Type) = Provable (Found (TyPP t)) Source #
If T :: k -> v ->
is a type constructor, then Type
is a constraint that Selectable
TT
is "selectable", in that you have
a canonical function:
selectTC
::Sing
a -> Σ v (TyPP
T x)
That is, given an x :: k
, we can always find a y :: k
that
satisfies T x y
.
Is essentially Selectable
, except with type constructors k ->
instead of matchable type-level functions (that are Type
k ~>
). Useful because Type
selectTC
doesn't require anything fancy like
TypeApplications to use.
Since: 0.1.4.0
selectTC :: forall {k1} {v} (t :: k1 -> v -> Type). SelectableTC t => Prove (Found (TyPP t)) Source #
The canonical selecting function for
.SelectableTC
t
Note that because t
must be an injective type constructor, you can use
this without explicit type applications; the instance of SelectableTC
can be inferred from the result type.
Since: 0.1.4.0
type SearchableTC (t :: k1 -> v -> Type) = Decidable (Found (TyPP t)) Source #
If T :: k -> v ->
is a type constructor, then Type
is a constraint that SearchableTC
TT
is "searchable", in that you have
a canonical function:
searchTC
::Sing
x ->Decision
(Σ v (TyPP
T x))
That, given an x :: k
, we can decide whether or not a y :: v
exists
that satisfies T x y
.
Is essentially Searchable
, except with type constructors k ->
instead of matchable type-level functions (that are Type
k ~>
). Useful because Type
searchTC
doesn't require anything fancy like
TypeApplications to use.
Since: 0.1.4.0
searchTC :: forall {k1} {v} (t :: k1 -> v -> Type). SearchableTC t => Decide (Found (TyPP t)) Source #
The canonical selecting function for
.Searchable
t
Note that because t
must be an injective type constructor, you can use
this without explicit type applications; the instance of SearchableTC
can be inferred from the result type.
Since: 0.1.4.0
Combining
data OrP (a :: ParamPred k v) (b :: ParamPred k v) (c :: k) (d :: TyFun v Type) Source #
Disjunction on two ParamPred
s, with appropriate Searchable
instance. Priority is given to the left predicate.
Since: 0.1.3.0
data AndP (a :: ParamPred k v) (b :: ParamPred k u) (c :: k) (d :: TyFun (v, u) Type) Source #
Conjunction on two ParamPred
s, with appropriate Searchable
and
Selectable
instances.
Since: 0.1.3.0