[Haskell-beginners] cascade of if statements
Kim-Ee Yeoh
ky3 at atamo.com
Thu Nov 1 16:58:58 CET 2012
On Thu, Nov 1, 2012 at 5:03 AM, Emmanuel Touzery <etouzery at gmail.com> wrote:
> Thank you that is very interesting... this is really impressive with
> haskell that it's so "easy" to add such operators, that they don't need to
> be builtin.
>
This can't be emphasized enough to people starting out. Haskell doesn't
have operators in the same sense as other languages. All those punctuation
symbols are ordinary functions and can be user- or library-defined to mean
anything.
There are also primitive functions and functions defined via the FFI but
those aren't baked into the language either.
<tangential rant> There is a reason why the prelude is called as such and
not "the standard library", which is a term I don't think you can find in
the language specs. That said, people looking for "the standard library"
are usually directed to the Haskell Platform, again not because there _is_
such a thing, but because their needs are best met there.
-- Kim-Ee
On Thu, Nov 1, 2012 at 5:03 AM, Emmanuel Touzery <etouzery at gmail.com> wrote:
> Thank you that is very interesting... this is really impressive with
> haskell that it's so "easy" to add such operators, that they don't need to
> be builtin.
>
> Thanks for your time, it was not wasted!
>
>
> On Wed, Oct 31, 2012 at 6:26 PM, Daniel Trstenjak <
> daniel.trstenjak at gmail.com> wrote:
>
>>
>> On Wed, Oct 31, 2012 at 06:14:52PM +0100, Daniel Trstenjak wrote:
>> > (<&&>) :: Monad m => m Bool -> m Bool -> m Bool
>> > (<&&>) m1 m2 = do
>> > r1 <- m1
>> > if r1 then m2 else return False
>> >
>> >
>> > (<||>) :: Monad m => m Bool -> m Bool -> m Bool
>> > (<||>) m1 m2 = do
>> > r1 <- m1
>> > if r1 then return True else m2
>>
>> That the operators behave like the boolean ones we should have the same
>> fixity declarations:
>>
>> infixr 3 (<&&>)
>> infixr 2 (<||>)
>>
>>
>> Greetings,
>> Daniel
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121101/437d11f5/attachment.htm>
More information about the Beginners
mailing list