[Haskell-cafe] Re: help with Haskell programming

Thomas Davie tom.davie at gmail.com
Sun Apr 18 13:27:12 EDT 2010


To do this, you need not just fmap (composition), but also ap, or the combined form, liftA2:

func = liftA2 (||)

Bob

On 18 Apr 2010, at 18:21, Keith Sheppard wrote:

> Using composition can be tricky with more than one arg. I just want to
> be sure you're not really looking for something like:
> 
>> func :: (a -> Bool) -> (b -> Bool) -> (a -> b -> Bool)
> 
> keeping with your given type I think you're looking for something like:
> 
>> func f1 f2 x = (f1 x) || (f2 x)
> 
> I'm sure there is a nice way to do this with function composition but
> I still find composition less intuitive than explicit args in cases
> like this.
> 
> On Sun, Apr 18, 2010 at 1:00 PM, Mujtaba Boori <mujtaba.boori at gmail.com> wrote:
>> Thanks for helping me but I have another problem (sorry for asking) . I
>> tried to figure it out .
>> how about if I want to compare two kind with (&&) (||)  for
>> func :: (a -> Bool) -> (a -> Bool) -> (a -> Bool)
>> 
>> I tried some thing like
>> func = ((||) .)
>> This is the annoying part about Haskell . I can not understand composition .
>> 
>> On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori <mujtaba.boori at gmail.com>
>> wrote:
>>> 
>>> Hello I am kinda newbie in Haskell you can help help me with some
>>> programming
>>> I am trying to make function like for example
>>> func :: (a -> Bool) -> (a -> Bool)
>>> this function make calculation  and return bool . I want to be able to
>>> make bool True when It is False and False when it is True while returning
>>> the a.
>>> Thank you
>>> --
>>> Mujtaba Ali Alboori
>> 
>> 
>> 
>> --
>> Mujtaba Ali Alboori
>> 
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> 
>> 
> 
> 
> 
> -- 
> keithsheppard.name
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list