[Haskell-cafe] gathering position information lazily using
traverse
Felipe Lessa
felipe.lessa at gmail.com
Fri Sep 10 17:58:10 EDT 2010
Hmmmm...
On Fri, Sep 10, 2010 at 6:47 PM, Jan Christiansen
<jac at informatik.uni-kiel.de> wrote:
> instance Applicative Proj where
> pure = Proj . const
> Proj f <*> Proj x = Proj (\p -> f (False:p) (x (True:p)))
(pure f) <*> Proj x
=== Proj (const f) <*> Proj x
=== Proj (\p -> (const f) (False:p) (x (True:p)))
=== Proj (\p -> f (x (True:p)))
Proj f <*> (pure x)
=== Proj f <*> Proj (const x)
=== Proj (\p -> f (False:p) ((const x) (True:p)))
=== Proj (\p -> f (False:p) x))
> instance Applicative Proj where
> pure x = Pure x
> Pure f <*> Pure x = Pure (f x)
> Pure f <*> Proj x = Proj (\p -> f (x p))
> Proj f <*> Pure x = Proj (\p -> f p x)
> Proj f <*> Proj x = Proj (\p -> f (False:p) (x (True:p)))
(pure f) <*> Proj x
=== Pure f <*> Proj x
=== Proj (\p -> f (x p))
(Proj f) <*> (pure x)
=== Proj f <*> Pure x
=== Proj (\p -> f p x)
Was this difference intended?
Cheers! =)
--
Felipe.
More information about the Haskell-Cafe
mailing list