extensible-effects-1.0

Safe HaskellNone

Data.OpenUnion1

Description

Original work at: http:okmij.orgftpHaskellextensibleOpenUnion1.hs. Open unions (type-indexed co-products) for extensible effects. This implementation relies on _closed_ overlapping instances (or closed type function overlapping soon to be added to GHC).

Synopsis

Documentation

data Union r v Source

Where r is `t1 :> t2 ... :> tn`, `Union r v` can be constructed with a value of type `ti v`. Ideally, we should be be able to add the constraint `Member t r`.

Instances

inj :: (Functor t, Typeable1 t, Member t r) => t v -> Union r vSource

Construct a Union.

prj :: (Typeable1 t, Member t r) => Union r v -> Maybe (t v)Source

Try extracting the contents of a Union as a specific type.

prjForce :: (Typeable1 t, Member t r) => Union r v -> (t v -> a) -> aSource

decomp :: (Typeable1 t, Member t (t :> r)) => Union (t :> r) v -> Either (Union r v) (t v)Source

class Member t r Source

Instances

Member t r => Member t (:> t' r) 
Member t (:> t r) 

data a :> b Source

A sum data type, for composing effects In GHC 7.4, we should make it a list (:>) :: (* -> *) -> (* -> List) -> List

Instances

Member t r => Member t (:> t' r) 
Member t (:> t r) 

unsafeReUnion :: Union r w -> Union t wSource

Juggle types for a Union. Use cautiously.