[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 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, downTrans] swing

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

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

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! >

Re: [Haskell-cafe] Looking for pointfree version

2009-02-12 Thread Benja Fallenstein
On Thu, Feb 12, 2009 at 8:46 AM, Kim-Ee Yeoh 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) import Control.Monad.Reader -- for the (Monad (a ->))

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 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 `op` c, b `op` d)

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-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: 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