{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}{-
The HList library
(C) 2004, Oleg Kiselyov, Ralf Laemmel, Keean Schupke
A generic implementation of a type-safe cast. The specific coding
here is only shown for completeness' sake and it is explained in the
TR version of the paper. The shown coding does not rely on separate
compilation (while TypeCastGeneric1.hs does), but on some other tricks.
-}moduleData.HList.TypeCastGeneric2where-- We make everything self-contained to show that separate compilation-- is not needed.importData.HList.FakePrelude()-- hiding (TypeCast,typeCast){-----------------------------------------------------------------------------}-- The actual encodingclassTypeCastab|a->b,b->awheretypeCast::a->bclassTypeCast'tab|ta->b,tb->awheretypeCast'::t->a->bclassTypeCast''tab|ta->b,tb->awheretypeCast''::t->a->binstanceTypeCast'()ab=>TypeCastabwheretypeCastx=typeCast'()xinstanceTypeCast''tab=>TypeCast'tabwheretypeCast'=typeCast''instanceTypeCast''()aawheretypeCast''_x=x{-----------------------------------------------------------------------------}