[Haskell-cafe] ANN: package Boolean: Generalized booleans
conal at conal.net
Tue Jun 30 14:21:03 EDT 2009
Does this code compile? I'd expect that
instance Bool (Js JsBool) (Js r) where
violates the fundep, since it applies for *all* values of r, not just to
On Tue, Jun 30, 2009 at 8:53 AM, Sebastiaan Visser <sfvisser at cs.uu.nl>wrote:
> On Jun 30, 2009, at 5:24 PM, Conal Elliott wrote:
>> Hi Sebastiaan,
>> I like your extensions of generalized booleans to other common Haskell
>> I also prefer using type families to fundeps. In this case I didn't
>> because of some awkwardness with vector operations, but I'm going to try
>> I'm confused about your particular fundep choice. For instance,
>> class Bool f r | f -> r where
>> bool :: r -> r -> f -> r
>> false :: f
>> true :: f
>> Do you *really* mean that the boolean type f determines the value type r?
> Yes, that is really what I mean. This can be used to enforce that the
> return value of elimination can be restricted by the boolean type. This is
> especially useful when using GADTs to encode your domain language.
> data Js a where
> Prim :: String -> Js a -- Primitive embedding.
> App :: Js (a -> b) -> Js a -> Js b -- Function application.
> data JsBool
> Now the functional dependencies can be used to enforce that eliminating
> booleans in the Js domain always returns a value in the Js domain:
> instance Bool (Js JsBool) (Js r) where
> bool f t c = Prim "(function ifthenelse (f, t, c) c ? t : f)" `App` f
> `App` t `App` c
> true = Prim "true"
> false = Prim "false"
> Getting rid of this fundep and using type families will probably be a lot
> more intuitive.
> Any suggestions on how to enforce elimination to be able to go from `Js
> JsBool -> Js r' using other techniques?
>> Regards, - Conal
> Sebastiaan Visser
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe