<p dir="ltr">Cool, thanks for the info!</p>
<div class="gmail_quote">On Jun 7, 2014 9:37 PM, "adam vogt" <<a href="mailto:vogt.adam@gmail.com">vogt.adam@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Ben,<br>
<br>
<a href="http://hackage.haskell.org/package/HList-0.3.4.1/docs/Data-HList-TIC.html" target="_blank">http://hackage.haskell.org/package/HList-0.3.4.1/docs/Data-HList-TIC.html</a><br>
is very similar, though it uses -XDataKinds for the type-level list<br>
and has fewer operations. For the next release we're changing the<br>
type-indexed collections (TIP, TIC) to share most of the<br>
implementation with Record and Variant respectively.<br>
<br>
I believe it's unnecessary to involve Typeable. Since there's a list<br>
of possible types, you can store (Int, Any), where the Int is an index<br>
into that list, instead of using TypeRep for that index.<br>
<a href="http://code.haskell.org/~aavogt/HList/Data/HList/Variant.hs" target="_blank">http://code.haskell.org/~aavogt/HList/Data/HList/Variant.hs</a> has that<br>
implementation. Leaving out Typeable makes a difference as far as what<br>
is allowed, because Records using promoted strings as the labels do<br>
not have a Typeable instance in ghc-7.8.2.<br>
<br>
Regards,<br>
Adam<br>
<br>
On Sat, Jun 7, 2014 at 3:47 PM, Ben Foppa <<a href="mailto:benjamin.foppa@gmail.com">benjamin.foppa@gmail.com</a>> wrote:<br>
> Thanks, I wasn't aware of vinyl and compdata. I'll check them out.<br>
> I'm not very familiar with HList, but I was under the impression that it<br>
> provided intersection, not union, i.e. for every type in { x1 x2 ..}, an<br>
> HList has an element vs for SOME type  in {x1 x2 ..} a Union has an<br>
> element..<br>
><br>
><br>
> On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald<br>
> <<a href="mailto:carter.schonwald@gmail.com">carter.schonwald@gmail.com</a>> wrote:<br>
>><br>
>> There's also compdata<br>
>><br>
>><br>
>> On Saturday, June 7, 2014, Ben Foppa <<a href="mailto:benjamin.foppa@gmail.com">benjamin.foppa@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi cafe. On a use case whim, I made the open-union package<br>
>>> (<a href="https://github.com/RobotGymnast/open-union" target="_blank">https://github.com/RobotGymnast/open-union</a>), copying the basic idea from<br>
>>> extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on<br>
>>> the chance that there's already something like this around. Here's the basic<br>
>>> functionality:<br>
>>><br>
>>> {-# LANGUAGE TypeOperators #-}<br>
>>> {-# LANGUAGE ScopedTypeVariables #-}<br>
>>> import Data.OpenUnion<br>
>>><br>
>>> type MyUnion = Union (Char :| Int :| [()] :| Void)<br>
>>><br>
>>> showMyUnion :: MyUnion -> String<br>
>>> showMyUnion<br>
>>>     =  (\(c :: Char) -> "char: " ++ show c)<br>
>>>     @> (\(i :: Int) -> "int: " ++ show i)<br>
>>>     @> (\(l :: [()]) -> "list length: " ++ show (length l))<br>
>>>     @> typesExhausted<br>
>>><br>
>>> main :: IO ()<br>
>>> main = do<br>
>>>     putStrLn $ showMyUnion $ liftUnion (4 :: Int)<br>
>>>     putStrLn $ showMyUnion $ liftUnion 'a'<br>
>>>     putStrLn $ showMyUnion $ liftUnion [(), ()]<br>
>>><br>
>>><br>
>>> If any of the (@>) cases is omitted, a compile-time error occurs. If you<br>
>>> try to lift a bad value to the union, a compile-time error occurs.<br>
>>><br>
>>> Any thoughts? Is there already something like this around?<br>
><br>
><br>
><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
</blockquote></div>