cubix-compdata-1.0.1: Compositional Data Types for Cubix
CopyrightOriginals (c) 2011 Patrick Bahr; modifications (c) 2017 Jmase koppel
LicenseBSD3
Safe HaskellNone
LanguageHaskell98

Data.Comp.Multi

Description

This module defines the infrastructure necessary to use Generalised Compositional Data Types. Generalised Compositional Data Types is an extension of Compositional Data Types with mutually recursive data types, and more generally GADTs. Examples of usage are bundled with the package in the library examples/Examples/Multi.

This is a fork of Patrick Bahrs compdata package. The chief differences are that the representation of sums has been replaced with a version that uses constant memory, and the portions of the library for single-sorted terms have been removed to speed compilation times. There are several minor changes and additions to the utility functions of this library.

Synopsis

Documentation

data Dict (c :: k -> Constraint) (a :: k) where Source #

A reified Constraint. Similar in spirit to Dict from ekmett's constraints package, but that definition has a kind of @Constraint -> */

Constructors

Dict :: c a => Dict c a 

class All (c :: k -> Constraint) (fs :: [k]) Source #

An instance of All c fs holds if c f holds for all f in fs.

Example: All HFunctor '[Add, Mul] holds if there are HFunctor instances for signatures Add and Mul.

The primary way to consume an All instance is with the caseCxt function. E.g.:

class Pretty f where
  pretty :: f e l -> String

instance (All Pretty fs) => Pretty (Sum fs) where
  pretty x = caseCxt (Proxy @Pretty) pretty x

Minimal complete definition

dicts

Instances

Instances details
All (c :: k -> Constraint) ('[] :: [k]) Source # 
Instance details

Defined in Data.Comp.Dict

Methods

dicts :: Proxy# '[] -> [E (Dict c)]

(All c fs, c f) => All (c :: a -> Constraint) (f ': fs :: [a]) Source # 
Instance details

Defined in Data.Comp.Dict

Methods

dicts :: Proxy# (f ': fs) -> [E (Dict c)]

withDict :: Dict c a -> (c a => r) -> r Source #

Puts the typeclass instance of a Dict back into the context.

(\\) :: (c a => r) -> Dict c a -> r infixl 1 Source #

Inline version of withDict

dictFor :: forall c f fs. All c fs => Elem f fs -> Dict c f Source #

If All c fs holds, and e is type-level proof that f is in fs, then dictFor e is the instance of c for f

This uses unsafeCoerce under the hood, but is safe if e is constructed by the public API.