| Copyright | (c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul Brauner |
|---|---|
| License | BSD3 |
| Maintainer | westbrook@kestrel.edu |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell98 |
Data.Binding.Hobbits.NuMatching
Description
This module defines the typeclass , which allows
pattern-matching on the bodies of multi-bindings when their bodies
have type a. To ensure adequacy, the actual machinery of how this
works is hidden from the user, but, for any given (G)ADT NuMatching aa, the
user can use the Template Haskell function mkNuMatching to
create a NuMatching instance for a.
- class NuMatching a where
- mkNuMatching :: Q Type -> Q [Dec]
- class NuMatchingList args where
- nuMatchingListProof :: MapRList NuMatchingObj args
- class NuMatching1 f where
- nuMatchingProof1 :: NuMatching a => NuMatchingObj (f a)
- data MbTypeRepr a
Documentation
class NuMatching a where Source
Instances of the class allow pattern-matching on
multi-bindings whose bodies have type NuMatching aa, i.e., on multi-bindings
of type . The structure of this class is mostly hidden
from the user; see Mb ctx amkNuMatching to see how to create instances
of the NuMatching class.
Methods
Instances
| NuMatching Char Source | |
| NuMatching Int Source | |
| NuMatching Integer Source | |
| NuMatching () Source | |
| NuMatching a => NuMatching [a] Source | |
| NuMatching (Cl a) Source | |
| NuMatching (Name a) Source | |
| NuMatching (Term a) Source | |
| NuMatching (Decls a) Source | |
| NuMatching (Decl a) Source | |
| NuMatching (DTerm a) Source | |
| (NuMatching a, NuMatching b) => NuMatching (a -> b) Source | |
| (NuMatching a, NuMatching b) => NuMatching (Either a b) Source | |
| (NuMatching a, NuMatching b) => NuMatching (a, b) Source | |
| (NuMatching1 f, NuMatchingList ctx) => NuMatching (MapRList f ctx) Source | |
| NuMatching (Member c a) Source | |
| NuMatching a => NuMatching (Mb ctx a) Source | |
| (NuMatching a, NuMatching b, NuMatching c) => NuMatching (a, b, c) Source | |
| (NuMatching a, NuMatching b, NuMatching c, NuMatching d) => NuMatching (a, b, c, d) Source |
mkNuMatching :: Q Type -> Q [Dec] Source
Template Haskell function for creating NuMatching instances for (G)ADTs.
Typical usage is to include the following line in the source file for
(G)ADT T (here assumed to have two type arguments):
$(mkNuMatching [t| forall a b . T a b |])
The mkNuMatching call here will create an instance declaration for
. It is also possible to include a context in the
forall type; for example, if we define the NuMatching (T a b)ID data type as follows:
data ID a = ID a
then we can create a NuMatching instance for it like this:
$( mkNuMatching [t| NuMatching a => ID a |])
Note that, when a context is included, the Haskell parser will add
the forall a for you.
class NuMatchingList args where Source
Methods
nuMatchingListProof :: MapRList NuMatchingObj args Source
Instances
| NuMatchingList (RNil *) Source | |
| (NuMatchingList args, NuMatching a) => NuMatchingList ((:>) * args a) Source |
class NuMatching1 f where Source
Methods
nuMatchingProof1 :: NuMatching a => NuMatchingObj (f a) Source
data MbTypeRepr a Source
This type states that it is possible to replace free names with
fresh names in an object of type a. This type essentially just
captures a representation of the type a as either a Name type, a
multi-binding, a function type, or a (G)ADT. In order to be sure
that only the "right" proofs are used for (G)ADTs, however, this
type is hidden from the user, and can only be constructed with
mkNuMatching.