November 2015
Intermediate to advanced
166 pages
3h 14m
English
As a unifying example for the next sections, we return to Chapter 6: Patterns of Generic Programming, where we created a List' type along with its type representation RList:
data List' a = Nil' | Cons' a (List' a) deriving (Show) data U = U deriving (Show) data Choice a b = L a | R b deriving (Show) data Combo a b = Combo a b deriving (Show) type RList a = Choice U (Combo a (List' a))
In addition to this, we defined functions fromL and toL to mediate between the type and representation:
fromL :: List' a -> RList a toL :: RList a -> List' a
We embedded this in the container type EP as follows:
data EP d r = EP {from_ :: (d -> r),
to_ :: (r -> d)}Instead of the container type EP mentioned above, ...
Read now
Unlock full access