Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Maybe and Just (Joel Neely)
   2. Re:  Monoids and Groups (Boris)
   3.  Something like pydoc? (Mike Meyer)
   4. Re:  Something like pydoc? (David McBride)


----------------------------------------------------------------------

Message: 1
Date: Thu, 26 Mar 2015 07:37:28 -0500
From: Joel Neely <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Maybe and Just
Message-ID:
        <CAEEzXAg_Y8Q2e2vTLYDkAx-xLPE-AYB07m72jT2p=nt17_c...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi, Shishir,

As a recovering complexity addict (i.e. Java programmer ;-), I'd put it
this way.

There are many methods (on many types) that can either succeed and return a
meaningful value, or be unable to fulfill the intent of the caller's
request. Example include indexOf on String,  get on Map, and read on a
Reader. Every time such a partial function scenario occurs, the author must
decide what to do if the intent can't be fulfilled. That freedom of choice
has led to a proliferation of techniques.


   - indexOf returns -1, which is a valid int, but not a valid position
   within a string.
   - get returns null, which is the only value common to all reference
   types that means 'I have nothing'. Of course, that also prevents one from
   storing null in a Map and simply retrieving it. Worse, if that result is
   passed along elsewhere, one can eventually receive a NullPointerException
   occurring in a completely different part of the code.
   - And, *horrors!*, read responds in a totally different way, by forcing
   the caller to "jump" somewhere.


Maybe provides a general, reusable solution to all such cases.

   - It allows one to "stretch" any type to include an extra "out of band"
   value.
   - The type declaration clearly (uniformly) notifies anyone else that the
   function may have to return "lack of result".
   - The type system prevents a caller from simply assuming that a result
   is present, and then accidentally propagating failure.
   - Because Maybe is an instance of Functor, one can use map to safely
   apply a function (or do nothing gracefully) without littering the calling
   code with if-statements.
   - etc.


I don't think of Maybe as enabling a *computation* that is impossible
otherwise, but I do regard it as providing a *consistency and simplicity*
that is otherwise not present.

Hope this helps,
Joel


On Thu, Mar 26, 2015 at 5:06 AM, Shishir Srivastava <
[email protected]> wrote:

> Hi,
>
> After reading and re-reading the haskell tutorials I don't happen to see a
> very convincing or appealing reason for having these data types.
>
> Can anyone please explain where Maybe and Just provide the sort of
> functionality that cannot be achieved in other languages which don't have
> these kind.
>
> Thanks,
> Shishir Srivastava
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150326/7a3f42cc/attachment-0001.html>

------------------------------

Message: 2
Date: Thu, 26 Mar 2015 15:17:37 +0200
From: Boris <[email protected]>
To: Shishir Srivastava <[email protected]>, The
        Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Monoids and Groups
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hi,

While they have similarities, they are not the same. Semigroup (S,*) is a set S 
with associative binary operation *. Monoid is a semigroup that has identity 
element i such that i * a = a and a * i = a. And group is a monoid in which 
every element of set has it?s own inverse: a * b = i and b * a = i where b is 
an inverse of a.

Let?s look at the definition of Monoid in haskell.

class Monoid a where
        mempty  :: a
        -- ^ Identity of 'mappend'
        mappend :: a -> a -> a
        -- ^ An associative operation
        mconcat :: [a] -> a

        -- ^ Fold a list using the monoid.
        -- For most types, the default definition for 'mconcat' will be
        -- used, but the function is included in the class definition so
        -- that an optimized version can be provided for specific types.

        mconcat = foldr mappend mempty
So we have a set of a, associative binary operation mappend and identity 
element mempty. The only difference between Monoid a in haskell and monoid in 
algebra is that Monoid in haskell has mconcat function in it?s definition. But 
you can ignore it.

I hope it helps.

Cheers, d12frosted


On March 25, 2015 at 16:03:14, Shishir Srivastava 
([email protected]) wrote:

Hi,?

Reading about Monoids it seems they derive a lot on the algebraic structures of 
'Groups' ??

Is it then correct to assume that Monoids can be used to represent 'Groups' ?

If not are there any standard haskell libraries which represent algebraic 
structures such as 'Groups' , 'Fields' etc.

Thanks,
Shishir Srivastava

_______________________________________________  
Beginners mailing list  
[email protected]  
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150326/ec0ef599/attachment-0001.html>

------------------------------

Message: 3
Date: Thu, 26 Mar 2015 08:36:30 -0500
From: Mike Meyer <[email protected]>
To: beginners <[email protected]>
Subject: [Haskell-beginners] Something like pydoc?
Message-ID:
        <CAD=7u2d_egh471tg_3igtcfryw8ndf2wxtj-zuddz2zxtdu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Python had the "pydoc" command, which would could be used to print a
module's docstings from the command line, and provided the "help" function
in the REPL. Clojure has "doc" in the REPL, at least if you told it where
the sources were.

I can't seem to find anything like that for Haskell - either at the command
line or in ghci. Does such exist? Is such possible?

Thanks,
<mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150326/7c4af12f/attachment-0001.html>

------------------------------

Message: 4
Date: Thu, 26 Mar 2015 09:44:19 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Something like pydoc?
Message-ID:
        <can+tr40arpa_qrapuc53gnhgftmsnxkib4k1rfipmk5gs+d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

There is a hoogle command: https://hackage.haskell.org/package/hoogle.

I don't use it, but I imagine you would have to set documention: True in
cabal.config, so you get documentation for any packages you have, and then
either use your browser, or put an alias in your .ghci to query it in your
repl, or just use the executable.

On Thu, Mar 26, 2015 at 9:36 AM, Mike Meyer <[email protected]> wrote:

> Python had the "pydoc" command, which would could be used to print a
> module's docstings from the command line, and provided the "help" function
> in the REPL. Clojure has "doc" in the REPL, at least if you told it where
> the sources were.
>
> I can't seem to find anything like that for Haskell - either at the
> command line or in ghci. Does such exist? Is such possible?
>
> Thanks,
> <mike
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150326/dfc040ff/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 81, Issue 63
*****************************************

Reply via email to