copilot-core-3.2.1: An intermediate representation for Copilot.
Safe HaskellSafe
LanguageHaskell2010

Copilot.Core.Type.Dynamic

Description

An implementation of dynamic types using Copilot.Core.Type.Equality. The theory behind this technique is described the following paper:

  • Baars, Arthur I. and Swierstra, S. Doaitse, "Typing dynamic typing", ACM SIGPLAN Notices vol. 37, p. 157-166, 2002
Synopsis

Documentation

data Dynamic :: (* -> *) -> * where Source #

Representation of a value accompanied by its type.

Constructors

Dynamic :: a -> t a -> Dynamic t 

data DynamicF :: (* -> *) -> (* -> *) -> * where Source #

Representation of a function accompanied by its type.

Constructors

DynamicF :: f a -> t a -> DynamicF f t 

toDyn :: t a -> a -> Dynamic t Source #

Enclose a value and its type in a container.

fromDyn :: EqualType t => t a -> Dynamic t -> Maybe a Source #

Extract a value from a dynamic. Return Nothing if the value is not of the given type.

toDynF :: t a -> f a -> DynamicF f t Source #

Enclose a function and its type in a container.

fromDynF :: EqualType t => t a -> DynamicF f t -> Maybe (f a) Source #

Extract a value from a dynamic function container. Return Nothing if the value is not of the given type.