On Thu, Sep 15, 2011 at 7:51 AM, Markus Läll wrote:
> Intuitively it seems to be exactly the same as the type families'
> aproach, and looks quite clear too.
Not exact, no--as written, it's strictly more powerful. Your fundeps
go in both directions, whereas the type families didn't (though could
Using fundeps I came up with this:
class T funs arg res | funs -> arg res, arg res -> funs where
tuple :: funs -> arg -> res
instance (a ~ a0, a0 ~ a1) => T (a0 -> b, a1 -> c) a (b, c) where
tuple (f, g) a = (f a, g a)
instance (a ~ a0, a0 ~ a1, a1 ~ a2) => T (a0 -> b, a1 -> c, a2 -> d) a
On 14/09/2011, at 2:45 PM, Casey McCann wrote:
>
>class Tuple t where
>type Arg t :: *
>type Result t :: *
>tuple :: t -> Arg t -> Result t
>
>instance (x1 ~ x2) => Tuple (x1 -> a, x2 -> b) where
>type Arg (x1 -> a, x2 -> b) = x1
>type Result (x1
On Wed, Sep 14, 2011 at 9:32 AM, Victor Nazarov
wrote:
> I've just tried another approach (code below). And GHC even inferred
> type for tupleF. But I think GHC inferred the wrong type and I can't
> formulate the right one, it seems to require infinite number of
> constraints. With GHC inferred ty
On Wed, Sep 14, 2011 at 6:45 AM, Casey McCann wrote:
> On Tue, Sep 13, 2011 at 10:03 PM, Chris Smith wrote:
>> Ah, okay... then sure, you can do this:
>>
>> class Tuple a b c | a b -> c where
>> tuple :: a -> b -> c
>>
>> instance Tuple (a -> b, a -> c) a (b,c) where
>> tuple (f,g) x = (f x
On Tue, Sep 13, 2011 at 10:03 PM, Chris Smith wrote:
> Ah, okay... then sure, you can do this:
>
> class Tuple a b c | a b -> c where
> tuple :: a -> b -> c
>
> instance Tuple (a -> b, a -> c) a (b,c) where
> tuple (f,g) x = (f x, g x)
This wouldn't actually work well in practice. There's n
On Wed, 2011-09-14 at 13:56 +1200, Richard O'Keefe wrote:
> I don't *expect* to implement anything just once. I am perfectly
> happy writing as many instance declarations as I have tuple sizes
> that I care about.
Ah, okay... then sure, you can do this:
class Tuple a b c | a b -> c where
tup
On 14/09/2011, at 1:44 PM, Chris Smith wrote:
> On Wed, 2011-09-14 at 13:35 +1200, Richard O'Keefe wrote:
>> I would like to have
>>
>> tuple (f1,f2) x = (f1 x, f2 x)
>> tuple (f1,f2,f3)x = (f1 x, f2 x, f3 x)
> There is no polymorphism across tuple structures,
I know that.
On Wed, 2011-09-14 at 13:35 +1200, Richard O'Keefe wrote:
> I would like to have
>
> tuple (f1,f2) x = (f1 x, f2 x)
> tuple (f1,f2,f3)x = (f1 x, f2 x, f3 x)
> tuple (f1,f2,f3,f4) x = (f1 x, f2 x, f3 x, f4 x)
> ...
>
> I'm aware of Control.Arrow and the &&& combin
I would like to have
tuple (f1,f2) x = (f1 x, f2 x)
tuple (f1,f2,f3)x = (f1 x, f2 x, f3 x)
tuple (f1,f2,f3,f4) x = (f1 x, f2 x, f3 x, f4 x)
...
I'm aware of Control.Arrow and the &&& combinator, and I can use that
instead, but f1 &&& f2 &&& f3 doesn't hav
10 matches
Mail list logo