yoko-0.1: generic programming with disbanded constructors

Portabilitysee LANGUAGE pragmas (... GHC)



Representations of many Haskell types as compositions of Data.Yoko.Core types.



data family RM m c Source

RM stands is for "recursively mediated", and m is the "mediator (of recursive occurrences)".

  data instance RM m V
  data instance RM m U = U
  newtype instance RM m (D a) = D a
  newtype instance RM m (R t) = R (Med m t)
  newtype instance RM m (F f c) = F (f (RM m c))
  newtype instance RM m (FF ff c d) = FF (ff (RM m c) (RM m d))
  newtype instance RM m (M i c) = M (RM m c)

type RMN m dc = RM m (N dc)Source

In yoko, the N core type is used for a lightweight representation of constructor types -- each will define its own instance of RM (N _).

type RMNI dc = RMN IdM dcSource

class Generic a whereSource

Generic represents a recursion-mediated type N a as a recursion-mediated Rep a. The opposite of "representation" is (the represented) "object".


rep :: RM m (N a) -> RM m (Rep a)Source

obj :: RM m (Rep a) -> RM m (N a)Source

unD :: RM m (D a) -> aSource

unM :: RM m (M i c) -> RM m cSource

unR :: RM m (R t) -> Med m tSource

absurd :: String -> RM m V -> aSource