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 one. - Conal On Tue, Jun 30, 2009 at 8:53 AM, Sebastiaan Visser <sfvis...@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 >> types! >> >> 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 >> again. >> >> 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. > > For example, take this simple JavaScript 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 > > > > []
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe