[Haskell-cafe] Re: Pickling HList

Joel Reymont joelr1 at gmail.com
Thu Nov 10 10:45:59 EST 2005


Credit goes to Cale:

class (HList l, HList p) => HLPU p l | p -> l, l -> p where
     puHList :: p -> PU l

instance HLPU HNil HNil where
     puHList HNil = lift HNil

instance (HList l, HLPU p l) => HLPU (HCons (PU e) p) (HCons e l) where
     puHList (HCons pe l) =
         wrap (\(a, b) -> HCons a b,
               \(HCons a b) -> (a, b))
                   (pair pe (puHList l))


On Nov 10, 2005, at 2:04 PM, Joel Reymont wrote:

> Folks,
>
> I'm having trouble creating a pickler for HLists and would  
> appreciate a solution.
>
> The code for (HCons e HNil) works fine but I get an error trying to  
> implement puHList for (HCons e l) where l is supposed to be (HCons  
> e ...), i.e. another HList.
>
> Bar.hs:21:37:
> Couldn't match the rigid variable e' against PU e'
> `e' is bound by the instance declaration at Bar.hs:17:0
>
> Expected type: HCons (PU e) l Inferred type: HCons e l
> In the first argument of puHList', namely l'
>
> In the second argument of pair', namely (puHList l)'
>
> Failed, modules loaded: none.
>

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list