hobbits-1.2.4: A library for canonically representing terms with binding

Copyright(c) 2014 Edwin Westbrook Nicolas Frisby and Paul Brauner
LicenseBSD3
Maintainerwestbrook@kestrel.edu
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Data.Binding.Hobbits.NuMatching

Description

This module defines the typeclass NuMatching a, 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 a, the user can use the Template Haskell function mkNuMatching to create a NuMatching instance for a.

Synopsis

Documentation

class NuMatching a where Source #

Instances of the NuMatching a class allow pattern-matching on multi-bindings whose bodies have type a, i.e., on multi-bindings of type Mb ctx a. The structure of this class is mostly hidden from the user; see mkNuMatching to see how to create instances of the NuMatching class.

Minimal complete definition

nuMatchingProof

Instances

NuMatching Bool Source # 
NuMatching Char Source # 
NuMatching Int Source # 
NuMatching Integer Source # 
NuMatching () Source # 
NuMatching a => NuMatching [a] Source # 
NuMatching a => NuMatching (Maybe a) Source # 
NuMatching (Name a) Source # 
NuMatching (Closed a) Source # 
NuMatching (Term a0) Source # 
NuMatching (Decls a0) Source # 
NuMatching (Decl a0) Source # 
NuMatching (DTerm a0) Source # 
(NuMatching a, NuMatching b) => NuMatching (a -> b) Source # 

Methods

nuMatchingProof :: MbTypeRepr (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 # 

Methods

nuMatchingProof :: MbTypeRepr (a, b, c) Source #

(NuMatching a, NuMatching b, NuMatching c, NuMatching d) => NuMatching (a, b, c, d) Source # 

Methods

nuMatchingProof :: MbTypeRepr (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 NuMatching (T a b). It is also possible to include a context in the forall type; for example, if we define the 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 NuMatching1 f where Source #

Minimal complete definition

nuMatchingProof1

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.

isoMbTypeRepr :: NuMatching b => (a -> b) -> (b -> a) -> MbTypeRepr a Source #

Build an MbTypeRepr for type a by using an isomorphism with an already-representable type b. This is useful for building NuMatching instances for, e.g., Integral types, by mapping to and from Integer, without having to define instances for each one in this module.

data NuMatchingObj a Source #

Constructors

NuMatching a => NuMatchingObj ()