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
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
> 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
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
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
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!
>
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 ->))
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)
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).
_
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
> 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
11 matches
Mail list logo