[Haskell-cafe] Object oriented haskell.

adam vogt vogt.adam at gmail.com
Thu May 15 23:06:15 UTC 2014


Hi Silvio,

.*. has always been a function.
http://hackage.haskell.org/package/HList-0.3.4.1/docs/Data-HList-HListPrelude.html#t:HExtend
is the current definition. The operations for lookup/update etc. need
to be rewritten to use closed type families as you did for lookup,
since GHC doesn't allow type families to use type classes. If it did,
then we could do the following:

instance (HasField l (Record r) v,
           Output (Record r) (Label l) ~ v)
       => Action (Record r) (Label l)
 where (.) = flip hLookupByLabel

type instance Output (Record r) (Label l) = (HasField l (Record r) v)
=> v -- not allowed

Regards,
Adam

On Thu, May 15, 2014 at 5:12 PM, silvio <silvio.frischi at gmail.com> wrote:
> I read over the first few example and it does not collide with my
> library. In fact, It could benefit from my library. From both (.) as
> well as the label construction. Actually I didn't get how they make the
> labels (getX).
>
> type instance Output (a .*. b) label = OOOutput (a .*. b) label
> type family OOOutput where
>         OOOutput (label .=. out .*. rest) label = out
>         OOOutput (noMatch .*. rest) label = OOOutput rest label
> instance Action (label .=. out .*. rest) label where
>         (_ .=. action .*. _) . _ = action
> instance Action (noMatch .*. rest) label where
>         (_ .*. rest) . b = rest . b
>
> I didn't compile this since i didn't have their code so there are
> probably some errors. Also I assumed their .*. are typeOperators even
> though they don't start with a :. But the idea should be clear.
>
> silvio
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list