Re: Re: [Haskell-cafe] Looking for pointfree version

2009-02-15 Thread Kim-Ee Yeoh
import Control.Applicative data Pair a = a :*: a instance Functor Pair where f `fmap` (x :*: y) = f x :*: f y instance Applicative Pair where (f :*: g) * (x :*: y) = f x :*: f y The last f needs to be a g. pure x = x :*: x pointfree :: (a - b - c) - Pair a -

Re: [Haskell-cafe] Looking for pointfree version

2009-02-15 Thread Conal Elliott
And then to down = mconcat [downPar, downNew, downTrans] Which is pretty cute considering that the original formulation is equivalent to and a tiny tweak away from down p = mconcat [downPar p, downNew p, downTrans p] Hooray for Monoid! - Conal On Mon, Feb 9, 2009 at 6:31 AM, Wouter

Re: [Haskell-cafe] Looking for pointfree version

2009-02-12 Thread Toby Hutton
On Thu, Feb 12, 2009 at 6:46 PM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote: On the same note, does anyone have ideas for the following snippet? Tried the pointfree package but the output was useless. pointwise op (x0,y0) (x1,y1) = (x0 `op` x1, y0 `op` y1) $ pointfree '(\op (a, b) (c, d) - (a

Re: [Haskell-cafe] Looking for pointfree version

2009-02-12 Thread Henning Thielemann
On Mon, 9 Feb 2009, Edsko de Vries wrote: Hi, Is there a nice way to write down :: Focus - [Focus] down p = concat [downPar p, downNew p, downTrans p] down = concat . sequence [downPar, downNew, downTrans] given the Reader like Monad instance of ((-) a).

Re: [Haskell-cafe] Looking for pointfree version

2009-02-11 Thread Kim-Ee Yeoh
On the same note, does anyone have ideas for the following snippet? Tried the pointfree package but the output was useless. pointwise op (x0,y0) (x1,y1) = (x0 `op` x1, y0 `op` y1) Edsko de Vries wrote: Perfect! Beautiful. I was hoping there'd be a simple solution like that. Thanks!

[Haskell-cafe] Looking for pointfree version

2009-02-09 Thread Edsko de Vries
Hi, Is there a nice way to write down :: Focus - [Focus] down p = concat [downPar p, downNew p, downTrans p] in point-free style? (In doesn't make much difference what these functions do; if it helps, their types are downPar, downNew, downTrans :: Focus - [Focus]). Ideally, I would like

Re: [Haskell-cafe] Looking for pointfree version

2009-02-09 Thread Robin Green
On Mon, 9 Feb 2009 14:18:18 + Edsko de Vries devri...@cs.tcd.ie wrote: Hi, Is there a nice way to write down :: Focus - [Focus] down p = concat [downPar p, downNew p, downTrans p] in point-free style? I think this should work: down = concat . swing map [downPar, downNew,

Re: [Haskell-cafe] Looking for pointfree version

2009-02-09 Thread Wouter Swierstra
snip How about using Data.Monoid: down = downPar `mappend` downNew `mappend` downTrans Wouter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Looking for pointfree version

2009-02-09 Thread Aai
Rewriting it to: concatMap ($ p)[downPar , downNew , downTrans ] gives: ($ p) = [downPar, downNew, downTrans] didn't check though! =@@i Edsko de Vries schreef: Hi, Is there a nice way to write down :: Focus - [Focus] down p = concat [downPar p, downNew p, downTrans p] in point-free

Re: [Haskell-cafe] Looking for pointfree version

2009-02-09 Thread Edsko de Vries
Perfect! Beautiful. I was hoping there'd be a simple solution like that. Thanks! On 9 Feb 2009, at 14:31, Wouter Swierstra wrote: snip How about using Data.Monoid: down = downPar `mappend` downNew `mappend` downTrans Wouter ___ Haskell-Cafe