type-iso-1.0.1.0: Typeclasses for injective relations and isomorphisms between types.

Safe HaskellNone
LanguageHaskell2010

Data.Types.Isomorphic

Description

Contains the class definition of Iso, indicating isomorphism between two types.

Synopsis

Documentation

class (Injective a b, Injective b a) => Iso a b Source #

The class of isomorphic types, i.e. those which can be cast to each other without loss of information. Type isomorphism is an equivalence relation (reflexive, symmetric, transitive), but due to the limitations of the type system, only reflexivity is implemented for all types. Since there are no type inequality constraints, writing symmetry and transitivity instances over all types would result in overlapping instances with due to reflexivity.

The following must be ensured:

Isomorphism
from . to = id

Reflexivity, symmetry and transitivity are then "free":

instance Iso a a
instance (Iso a b, Iso b c) => Iso a c

Out of these, only the first one (reflexivity) is actually implemented, since the other two would result in overlapping instances. We would be able to avoid this with type inequality constrains (e.g. a /~ b, a /~ c, b /~ c).

Instances
Iso Integer Whole Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso a a Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso String Text Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso String Text Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso Whole Integer Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso Text String Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso Text Text Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso Text String Source # 
Instance details

Defined in Data.Types.Isomorphic

Iso Text Text Source # 
Instance details

Defined in Data.Types.Isomorphic

Vector v a => Iso (v a) (Seq a) Source # 
Instance details

Defined in Data.Types.Isomorphic

Vector v a => Iso (Seq a) (v a) Source # 
Instance details

Defined in Data.Types.Isomorphic

from :: forall b a. Iso a b => b -> a Source #

Synonym for to.