<div dir="ltr"><div>Thanks, I wasn't aware of vinyl and compdata. I'll check them out.<br></div>I'm not very familiar with HList, but I was under the impression that it provided intersection, not union, i.e. for every type in { x1 x2 ..}, an HList has an element vs for SOME type  in {x1 x2 ..} a Union has an element..<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald <span dir="ltr"><<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's also compdata <div class="im HOEnZb"><span></span><br><br>On Saturday, June 7, 2014, Ben Foppa <<a href="mailto:benjamin.foppa@gmail.com" target="_blank">benjamin.foppa@gmail.com</a>> wrote:<br>
</div><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Hi cafe. On a use case whim, I made the open-union package (<a href="https://github.com/RobotGymnast/open-union" target="_blank">https://github.com/RobotGymnast/open-union</a>), copying the basic idea from extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on the chance that there's already something like this around. Here's the basic functionality:<br>


<pre><code>{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.OpenUnion

type MyUnion = Union (Char :| Int :| [()] :| Void)

showMyUnion :: MyUnion -> String
showMyUnion
    =  (\(c :: Char) -> "char: " ++ show c)
    @> (\(i :: Int) -> "int: " ++ show i)
    @> (\(l :: [()]) -> "list length: " ++ show (length l))
    @> typesExhausted

main :: IO ()
main = do
    putStrLn $ showMyUnion $ liftUnion (4 :: Int)
    putStrLn $ showMyUnion $ liftUnion 'a'
    putStrLn $ showMyUnion $ liftUnion [(), ()]</code><br></pre><br></div>If any of the (@>) cases is omitted, a compile-time error occurs. If you try to lift a bad value to the union, a compile-time error occurs.<br>


<div><br>Any thoughts? Is there already something like this around?<br></div></div>
</blockquote>
</div></div></blockquote></div><br></div>