Re: [Haskell-cafe] reifying typeclasses

2013-09-17 Thread Evan Laforge
Thanks to everyone who replied, indeed it looks like GADTs do what I claimed I wanted. That's neat because I've never been able to think of a use for them. However: On Sun, Sep 15, 2013 at 2:16 AM, o...@okmij.org wrote: Why not to introduce several type classes, even a type class for each

Re: [Haskell-cafe] reifying typeclasses

2013-09-17 Thread oleg
I've been toying with using Data Types a la Carte to get type representations, a `Typeable` class and dynamic types parameterized by a possibly open universe: If the universe is potentially open, and if we don't care about exhaustive pattern-matching check (which is one of the principal

Re: [Haskell-cafe] reifying typeclasses

2013-09-16 Thread Emil Axelsson
2013-09-15 11:16, o...@okmij.org skrev: Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being a typeclass forces them to all be defined in one place, breaking modularity. A

Re: [Haskell-cafe] reifying typeclasses (resend)

2013-09-15 Thread Timon Gehr
On 09/15/2013 09:38 AM, Evan Laforge wrote: ... It seems to me like I should be able to replace a typeclass with arbitrary methods with just two, to reify the type and back. This seems to work when the typeclass dispatches on an argument, but not on a return value. E.g.: ... Say m_argument

Re: [Haskell-cafe] reifying typeclasses

2013-09-15 Thread oleg
Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being a typeclass forces them to all be defined in one place, breaking modularity. A sum type, of course, wouldn't have that

Re: [Haskell-cafe] reifying typeclasses (resend)

2013-09-15 Thread Bas van Dijk
You can indeed use GADTs to solve this: {-# LANGUAGE GADTs #-} data Universe a where UInt :: Int - Universe Int UChar :: Char - Universe Char class Universal a where universe :: a - Universe a instance Universal Int where universe = UInt instance Universal Char where

Re: [Haskell-cafe] reifying typeclasses

2013-09-15 Thread oleg
[I too had the problem sending this e-mail to Haskell list. I got a reply saying the message awaits moderator approval] Evan Laforge wrote: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being