Re: Ternary operators in Haskell, an observation (was: [Haskell] Do the libraries define S' ?)

2004-08-03 Thread Graham Klyne
At 14:05 02/08/04 -0700, John Meacham wrote: You might be interested in my BooleanAlgebra class, which replaces the various boolean operators from the prelude with overloaded versions with various useful instances. The really nice thing is the instance for Bool is exactly the same as the prelude ve

Re: Ternary operators in Haskell, an observation (was: [Haskell] Do the libraries define S' ?)

2004-08-02 Thread John Meacham
On Mon, Aug 02, 2004 at 10:54:33PM +0200, [EMAIL PROTECTED] wrote: > The operators can be also defined as follows: >(.&.) f g x = (f x) && (g x) >(.|.) f g x = (f x) || (g x) > > It is clear from these definitions, that the operators are ternary > operators. > > As operators are essential

Ternary operators in Haskell, an observation (was: [Haskell] Do the libraries define S' ?)

2004-08-02 Thread hjgtuyl
On Wed, Jul 07, 2004 at 01:18:54PM +0100, Graham Klyne wrote: There's a pattern of higher-order function usage I find myself repeatedly wanting to use, exemplified by the following: [[ -- combineTest :: (Bool->Bool->Bool) -> (a->Bool) -> (a->Bool) -> (a->Bool) combineTest :: (b->c->d) -> (a->b)

Re: [Haskell] Do the libraries define S' ?

2004-07-09 Thread Ross Paterson
On Thu, Jul 08, 2004 at 08:36:57PM -0400, David Menendez wrote: > Conor T McBride writes: > > > >infixl 9 <%> -- my name for <# -- others have other names > >class Idiom i where > > idi :: x -> i x > > (<%>) :: i (s -> t) -> i s -> i t > > > > I call them idioms because it's li

Re: [Haskell] Do the libraries define S' ?

2004-07-09 Thread Graham Klyne
At 14:45 07/07/04 -0400, Andrew Pimlott wrote: This can be seen as liftM2 on the reader monad ((->) r): (.&.) = liftM2 (&&) Thanks to those who pointed out this. I think the ((->) r) reader monad is one of those I've yet to fully grasp. #g -- At 14:45 07/07/04 -0400, Andrew Pimlott wrote: > -- comb

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread David Menendez
Conor T McBride writes: > As some of you know, I like them a lot too. In fact, if you have a > return-like thing and an ap-like thing, you can make fmap as well. > (Note that the return for the environment monad is none other than > S's best friend K.) > > So I got hacking, a little while ago...

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Remi Turk
On Thu, Jul 08, 2004 at 03:47:08PM +1000, Bernard James POPE wrote: > I use almost exactly the same thing in my code. And I nearly came > up with the same names as you! (I have .&&. and .||.) > > I find them very useful in guards: > >foo x y > | (this .&&. that) x = ... > > I don't beli

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Conor T McBride
Hi folks Iavor S. Diatchki wrote: hi, you can use the reader (environment monad) for this. lately i have been using 2 combinators to do things like that (thanks to Thomas Hallgren for showing me this): -- a nicer name for fmap (or liftM if one prefers) (#) :: Functor f => (a -> b) -> f a -> f b

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Bernard James POPE
On Wed, Jul 07, 2004 at 01:18:54PM +0100, Graham Klyne wrote: > There's a pattern of higher-order function usage I find myself repeatedly > wanting to use, exemplified by the following: > > [[ > -- combineTest :: (Bool->Bool->Bool) -> (a->Bool) -> (a->Bool) -> (a->Bool) > combineTest :: (b->c->d)

Re: [Haskell] Do the libraries define S' ?

2004-07-07 Thread Iavor S. Diatchki
hi, you can use the reader (environment monad) for this. combineTest c t1 t2 = liftM2 c t1 t2 lately i have been using 2 combinators to do things like that (thanks to Thomas Hallgren for showing me this): -- a nicer name for fmap (or liftM if one prefers) (#) :: Functor f => (a -> b) -> f a ->

Re: [Haskell] Do the libraries define S' ?

2004-07-07 Thread Andrew Pimlott
On Wed, Jul 07, 2004 at 01:18:54PM +0100, Graham Klyne wrote: > There's a pattern of higher-order function usage I find myself repeatedly > wanting to use, exemplified by the following: > > [[ > -- combineTest :: (Bool->Bool->Bool) -> (a->Bool) -> (a->Bool) -> (a->Bool) > combineTest :: (b->c->d)

[Haskell] Do the libraries define S' ?

2004-07-07 Thread Graham Klyne
There's a pattern of higher-order function usage I find myself repeatedly wanting to use, exemplified by the following: [[ -- combineTest :: (Bool->Bool->Bool) -> (a->Bool) -> (a->Bool) -> (a->Bool) combineTest :: (b->c->d) -> (a->b) -> (a->c) -> a -> d combineTest c t1 t2 = \a -> c (t1 a) (t2 a)