cardano-data-1.2.3.1: Specialized data for Cardano project
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Universe

Description

The idea is to create a world of Haskell types, called a Universe. Then to define a 'class' whose methods are only applicable to that set of types. We define a closed set by defining an indexed type constructor Rep. If (Singleton Rep), then it must be that every value of type (Rep t) has exactly 0 or 1 inhabitants. (Rep t) has exactly 1 inhabitant if t is in the universe, and 0 inhabitants if it is not in the universe. A closely related class is (Indexed s t). We would like a total ordering on (t i) and (t j), where the indices, i and j, are different. We do this by ensuring every value of type (t i) has a unique Shape, and that the type Shape has a total order. Every closed singleton can be totally ordered this way. Other indexed types are used to make well-type terms. I.e. Indexed s t => Exp t, denotes a Haskell data type Exp, related to the type t. Note, unlike singletons, there may not be a unique value of type (Exp t), but there may be a unique Shape for every value.

Synopsis

Documentation

class Shaped t rep where Source #

For some indexed types, we can assign a unique Shape to each type, using: shape :: t i -> Shape s (where s is some Singleton type) the class (Shaped t s) means we can assign a unique Shape to each value of type (t i). Not quite as strong as having a unique inhabitant. Every closed singleton type can be shaped, and many other indexed types can be shaped as well.

Methods

shape ∷ t i → Shape rep Source #

class Singleton t where Source #

Given (Singleton T), a value of type (T i) has exactly 0 or 1 inhabitants, so we can compare the structure of the type to get proofs that the indexes (i and j) are the same type, using testEql, at runtime. cmpIndex, it is like compare except we can have two different indexes (a and b).

Methods

testEql ∷ t i → t j → Maybe (i :~: j) Source #

cmpIndex ∷ t a → t b → Ordering Source #

Instances

Instances details
Singleton (TypeRep ∷ k → Type) Source # 
Instance details

Defined in Data.Universe

Methods

testEql ∷ ∀ (i ∷ k0) (j ∷ k0). TypeRep i → TypeRep j → Maybe (i :~: j) Source #

cmpIndex ∷ ∀ (a ∷ k0) (b ∷ k0). TypeRep a → TypeRep b → Ordering Source #

class Singleton rep ⇒ Universe rep t where Source #

A minimal class of operations defined on the universe described by rep . Feel free to make your own Universe classes with additional methods

Methods

repOf ∷ rep t Source #

data Any t where Source #

Hide the index for any indexed type t

Constructors

Any ∷ t i → Any t 

Instances

Instances details
(∀ (i ∷ k). Show (t i)) ⇒ Show (Any t) Source # 
Instance details

Defined in Data.Universe

Methods

showsPrecIntAny t → ShowS #

showAny t → String #

showList ∷ [Any t] → ShowS #

data Some t where Source #

Hide the index for a singleton type t

Constructors

SomeSingleton t ⇒ t i → Some t 

Instances

Instances details
Eq (Some r) Source # 
Instance details

Defined in Data.Universe

Methods

(==)Some r → Some r → Bool #

(/=)Some r → Some r → Bool #

Ord (Some r) Source # 
Instance details

Defined in Data.Universe

Methods

compareSome r → Some r → Ordering #

(<)Some r → Some r → Bool #

(<=)Some r → Some r → Bool #

(>)Some r → Some r → Bool #

(>=)Some r → Some r → Bool #

maxSome r → Some r → Some r #

minSome r → Some r → Some r #

data Dyn rep where Source #

Constructors

DynSingleton t ⇒ t i → i → Dyn t 

data Shape rep where Source #

Constructors

NullaryIntShape rep 
NaryInt → [Shape rep] → Shape rep 
Esc ∷ (Singleton rep, Ord t) ⇒ rep t → t → Shape rep 

Instances

Instances details
Eq (Shape rep) Source # 
Instance details

Defined in Data.Universe

Methods

(==)Shape rep → Shape rep → Bool #

(/=)Shape rep → Shape rep → Bool #

Ord (Shape rep) Source # 
Instance details

Defined in Data.Universe

Methods

compareShape rep → Shape rep → Ordering #

(<)Shape rep → Shape rep → Bool #

(<=)Shape rep → Shape rep → Bool #

(>)Shape rep → Shape rep → Bool #

(>=)Shape rep → Shape rep → Bool #

maxShape rep → Shape rep → Shape rep #

minShape rep → Shape rep → Shape rep #

type Eql x y = x :~: y Source #

Type synonym, so we can use ( :~: ) without TypeOperators

data (a ∷ k) :~: (b ∷ k) where #

Constructors

Refl ∷ ∀ {k} (a ∷ k). a :~: a 

Instances

Instances details
TestEquality ((:~:) a ∷ k → Type) 
Instance details

Defined in Data.Type.Equality

Methods

testEquality ∷ ∀ (a0 ∷ k0) (b ∷ k0). (a :~: a0) → (a :~: b) → Maybe (a0 :~: b)

GCompare ((:~:) a ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

gcompare ∷ ∀ (a0 ∷ k0) (b ∷ k0). (a :~: a0) → (a :~: b) → GOrdering a0 b Source #

GEq ((:~:) a ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

geq ∷ ∀ (a0 ∷ k0) (b ∷ k0). (a :~: a0) → (a :~: b) → Maybe (a0 :~: b) Source #

GRead ((:~:) a ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

greadsPrecIntGReadS ((:~:) a) Source #

GShow ((:~:) a ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec ∷ ∀ (a0 ∷ k0). Int → (a :~: a0) → ShowS Source #

NFData2 ((:~:) ∷ Type → Type → Type) 
Instance details

Defined in Control.DeepSeq

Methods

liftRnf2 ∷ (a → ()) → (b → ()) → (a :~: b) → ()

NFData1 ((:~:) a) 
Instance details

Defined in Control.DeepSeq

Methods

liftRnf ∷ (a0 → ()) → (a :~: a0) → ()

a ~ b ⇒ Bounded (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

minBound ∷ a :~: b #

maxBound ∷ a :~: b #

a ~ b ⇒ Enum (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

succ ∷ (a :~: b) → a :~: b #

pred ∷ (a :~: b) → a :~: b #

toEnumInt → a :~: b #

fromEnum ∷ (a :~: b) → Int #

enumFrom ∷ (a :~: b) → [a :~: b] #

enumFromThen ∷ (a :~: b) → (a :~: b) → [a :~: b] #

enumFromTo ∷ (a :~: b) → (a :~: b) → [a :~: b] #

enumFromThenTo ∷ (a :~: b) → (a :~: b) → (a :~: b) → [a :~: b] #

a ~ b ⇒ Read (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

readsPrecIntReadS (a :~: b) #

readListReadS [a :~: b] #

readPrec ∷ ReadPrec (a :~: b) #

readListPrec ∷ ReadPrec [a :~: b] #

Show (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

showsPrecInt → (a :~: b) → ShowS #

show ∷ (a :~: b) → String #

showList ∷ [a :~: b] → ShowS #

NFData (a :~: b) 
Instance details

Defined in Control.DeepSeq

Methods

rnf ∷ (a :~: b) → ()

Eq (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

(==) ∷ (a :~: b) → (a :~: b) → Bool #

(/=) ∷ (a :~: b) → (a :~: b) → Bool #

Ord (a :~: b) 
Instance details

Defined in Data.Type.Equality

Methods

compare ∷ (a :~: b) → (a :~: b) → Ordering #

(<) ∷ (a :~: b) → (a :~: b) → Bool #

(<=) ∷ (a :~: b) → (a :~: b) → Bool #

(>) ∷ (a :~: b) → (a :~: b) → Bool #

(>=) ∷ (a :~: b) → (a :~: b) → Bool #

max ∷ (a :~: b) → (a :~: b) → a :~: b #

min ∷ (a :~: b) → (a :~: b) → a :~: b #

data TypeRep (a ∷ k) #

Instances

Instances details
TestEquality (TypeRep ∷ k → Type) 
Instance details

Defined in Data.Typeable.Internal

Methods

testEquality ∷ ∀ (a ∷ k0) (b ∷ k0). TypeRep a → TypeRep b → Maybe (a :~: b)

Singleton (TypeRep ∷ k → Type) Source # 
Instance details

Defined in Data.Universe

Methods

testEql ∷ ∀ (i ∷ k0) (j ∷ k0). TypeRep i → TypeRep j → Maybe (i :~: j) Source #

cmpIndex ∷ ∀ (a ∷ k0) (b ∷ k0). TypeRep a → TypeRep b → Ordering Source #

GCompare (TypeRep ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

gcompare ∷ ∀ (a ∷ k0) (b ∷ k0). TypeRep a → TypeRep b → GOrdering a b Source #

GEq (TypeRep ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

geq ∷ ∀ (a ∷ k0) (b ∷ k0). TypeRep a → TypeRep b → Maybe (a :~: b) Source #

GShow (TypeRep ∷ k → Type) 
Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec ∷ ∀ (a ∷ k0). IntTypeRep a → ShowS Source #

Show (TypeRep a) 
Instance details

Defined in Data.Typeable.Internal

Methods

showsPrecIntTypeRep a → ShowS #

showTypeRep a → String #

showList ∷ [TypeRep a] → ShowS #

Eq (TypeRep a) 
Instance details

Defined in Data.Typeable.Internal

Methods

(==)TypeRep a → TypeRep a → Bool #

(/=)TypeRep a → TypeRep a → Bool #

Ord (TypeRep a) 
Instance details

Defined in Data.Typeable.Internal

Methods

compareTypeRep a → TypeRep a → Ordering #

(<)TypeRep a → TypeRep a → Bool #

(<=)TypeRep a → TypeRep a → Bool #

(>)TypeRep a → TypeRep a → Bool #

(>=)TypeRep a → TypeRep a → Bool #

maxTypeRep a → TypeRep a → TypeRep a #

minTypeRep a → TypeRep a → TypeRep a #

Hashable (TypeRep a) 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSaltIntTypeRep a → Int Source #

hashTypeRep a → Int Source #

Typeable a ⇒ Serialise (TypeRep a)

Since: serialise-0.2.0.0

Instance details

Defined in Codec.Serialise.Class

compareByShape ∷ ∀ (rep ∷ Type → Type) (t ∷ Type → Type) (i ∷ Type) (j ∷ Type). Shaped t rep ⇒ t i → t j → Ordering Source #

Order two indexed types by their Shape. This is usefull for making (Singleton t) instances when we have (Shaped t r) instances, as cmpIndex can be compareByShape.