[Haskell-cafe] translating some C# abstractions into Haskell....
Nicholls, Mark
Nicholls.Mark at mtvne.com
Fri Dec 28 09:52:34 EST 2007
Lets say I've got
Interface IFoo<X,Y>
Where X : IBar
Where Y : IBar
{
}
Would seem to translate roughly to....
class (IBar x, IBar y) => IFoo foo x y
? (or does it?)
-----Original Message-----
From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Nicholls, Mark
Sent: 28 December 2007 11:30
To: Chaddaï Fouché
Cc: haskell-cafe at haskell.org
Subject: RE: [Haskell-cafe] what does @ mean?.....
Lovely....thank you very much....another small step forward.
-----Original Message-----
From: Chaddaï Fouché [mailto:chaddai.fouche at gmail.com]
Sent: 28 December 2007 11:29
To: Nicholls, Mark
Cc: Alfonso Acosta; haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] what does @ mean?.....
2007/12/28, Nicholls, Mark <Nicholls.Mark at mtvne.com>:
> So in the example given...
>
> mulNat a b
> | a <= b = mulNat' a b b
> | otherwise = mulNat' b a a
> where
> mulNat' x@(S a) y orig
> | x == one = y
> | otherwise = mulNat' a (addNat orig y) orig
>
> Is equivalent to
>
> mulNat a b
> | a <= b = mulNat' a b b
> | otherwise = mulNat' b a a
> where
> mulNat' (S a) y orig
> | (S a) == one = y
> | otherwise = mulNat' a (addNat orig y) orig
>
> ?
Yes, but in the second version, it has to reconstruct (S a) before
comparing it to "one" where in the first it could do the comparison
directly. In this cas there may be some optimisation involved that
negate this difference but in many case it can do a real performance
difference.
The "as-pattern" (@ means as) is both practical and performant in most cases.
--
Jedaï
_______________________________________________
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