[Haskell-cafe] Closed classes

Tobias Florek haskell at ibotty.net
Thu Feb 18 10:43:44 UTC 2016


Hi.

For consistency reasons, I'd love to write the following, possibly even
omiting the closed keyword.

> {-# LANGUAGE ClosedClasses #-}
> closed class Closed a b where
>   fun :: a -> b -> Int
>   instance Closed Int y where fun x _ = x
>   instance Closed x Int where fun _ y = y
>   instance Closed x y where fun _ _ = 0

I guess, that's already bikeshedding.

Cheers,
 Tobias Florek


More information about the Haskell-Cafe mailing list