[Haskell-cafe] Typeclass question
Miguel Mitrofanov
miguelimo38 at yandex.ru
Sat Dec 27 15:28:21 EST 2008
Oh! That's much simplier:
data Bar a => Foo a = Foo a Bool
On 27 Dec 2008, at 23:09, Andrew Wagner wrote:
> Hmm, I actually simplified my problem too much. What I actually want
> is:
> data Foo a = forall a. Bar a => Foo a Bool
>
> ...except I want the 'a' on the left to match the 'a' on the right,
> so that you can only construct values out of values of the
> parameterized type, which also must be of the Bar class.
>
> On Dec 27, 2008, at 1:44 PM, "David Menendez" <dave at zednenem.com>
> wrote:
>
>> On Sat, Dec 27, 2008 at 2:24 PM, Andrew Wagner <wagner.andrew at gmail.com
>> > wrote:
>>> I'm sure there's a way to do this, but it's escaping me at
>>> present. I want
>>> to do something like this:
>>>
>>> data Foo = Bar a => Foo a Bool ...
>>>
>>> That is, I want to create a new type, Foo, whose constructor takes
>>> both a
>>> Boolean and a value of a type of class Bar.
>>
>> Try this:
>>
>> {-# LANGUAGE ExistentialQuantification #-}
>>
>> data Foo = forall a. Bar a => Foo a Bool
>>
>>
>> --
>> Dave Menendez <dave at zednenem.com>
>> <http://www.eyrie.org/~zednenem/>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list