packages feed

tuple-hlist-0.1.0.6: Tools/IncompleteHList.hs

{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}

{- |
This module contains overloaded functions for creating an HList from a tuple or
a tuple from an HList.
-}
module Data.Tuple.HList (HLst(toHList, fromHList)) where

import Data.Tuple.OneTuple (OneTuple(OneTuple))
import Data.HList (HNil(HNil), HCons(HCons), (:*:), hEnd, hBuild)

class HLst a b | a -> b, b -> a where
    -- |Creates an HList from a tuple.
    toHList   :: a -> b
    -- |Creates a tuple from an HList.
    fromHList :: b -> a

instance HLst (OneTuple a1) (a1 :*: HNil) where
    toHList   (OneTuple a1)   = hEnd $ hBuild a1
    fromHList (HCons a1 HNil) = OneTuple a1

---- The code below is automatically generated by Tools/generateInstances.hs ----