Re: [Haskell-cafe] Should `(flip (^^))` work?

2008-09-15 Thread wren ng thornton

Mauricio wrote:

Hi,

I tested the expression below
and it doesn't work. Is there
some way to achieve that (i.e.,
turning an expression inside
parenthesis into an operator)?

2 `(flip (^^))` (3%4)


Another solution if you don't like defining extra (-|) and (|-) 
operators is:


  > ($2) (flip (^^)) (3%4)

The right section of function application is type lifting. The general 
form of this construction is:


  > ($x) (f a b c...) y z...

Which is equal to (f a b c... x y z...). That is, the construction lets 
you raise any argument out to before the function, thus making the 
partially applied function into an infix between |x| and |y x...|.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Should `(flip (^^))` work?

2008-09-15 Thread Rafael C. de Almeida
Derek Elkins wrote:
> On Mon, 2008-09-15 at 18:42 -0300, Mauricio wrote:
>> Hi,
>>
>> I tested the expression below
>> and it doesn't work. Is there
>> some way to achieve that (i.e.,
>> turning an expression inside
>> parenthesis into an operator)?
>>
>> 2 `(flip (^^))` (3%4)
> 
> No it shouldn't work.  The fact that the opening and closing marks are the 
> same suggests that it shouldn't.  You can fake it though.
> 
> x -| f = f x
> f |- x = f x
> 
> 2 -| flip (^^) |- (3%4)
> 

Isn't naming the expression 'flip (^^)' much clearer?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Should `(flip (^^))` work?

2008-09-15 Thread Derek Elkins
On Mon, 2008-09-15 at 18:42 -0300, Mauricio wrote:
> Hi,
> 
> I tested the expression below
> and it doesn't work. Is there
> some way to achieve that (i.e.,
> turning an expression inside
> parenthesis into an operator)?
> 
> 2 `(flip (^^))` (3%4)

No it shouldn't work.  The fact that the opening and closing marks are the same 
suggests that it shouldn't.  You can fake it though.

x -| f = f x
f |- x = f x

2 -| flip (^^) |- (3%4)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Should `(flip (^^))` work?

2008-09-15 Thread Mauricio

Hi,

I tested the expression below
and it doesn't work. Is there
some way to achieve that (i.e.,
turning an expression inside
parenthesis into an operator)?

2 `(flip (^^))` (3%4)

Thanks,
MaurĂ­cio

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe