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:  Help with a data type declaration
      (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   2.  State and Maybe and monad transformers (Andrew Bernard)
   3.  Haskell package maturity (Andrew Bernard)
   4. Re:  State and Maybe and monad transformers (Ben Kolera)
   5. Re:  Haskell package maturity (emacstheviking)


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

Message: 1
Date: Tue, 29 Sep 2015 21:05:47 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Help with a data type declaration
Message-ID:
        <CAJbEW8Oatp+Xp4oH_F53JHURVDDe9qcyR6b=rjgi92iodq9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

This Wikipedia article is a good read for getting the concepts right:
https://en.wikipedia.org/wiki/Algebraic_data_type

On 29 September 2015 at 20:57, Karl Voelker <[email protected]> wrote:

> On Tue, Sep 29, 2015, at 07:10 AM, [email protected] wrote:
> > * "Tree" is the name of the new type.
> > * "Branch" and "Leaf" are the type constructors.
> > * What is "a" and "b"?
>
> "Tree" is not quite the name of a type. It is the name of a type
> constructor - in other words, it is a "type-level function". This also
> explains "a" and "b" - they are the parameters to the type constructor
> (which means they are "type variables").
>
> To get a type, you have to apply the type constructor. So, for example,
> "Tree Char Int" is a type.
>
> "Branch" and "Leaf" are not type constructors - they are *data*
> constructors.
>
> > * It seems to me that this type is kind of "recursively" defined but I
> > do not know exactly.
>
> Yes. It's recursive because a value of type "Tree a b" can be built up
> from other values of type "Tree a b" (if you use the "Branch"
> constructor).
>
> -Karl
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150929/8b17c3d1/attachment-0001.html>

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

Message: 2
Date: Wed, 30 Sep 2015 14:22:21 +1000
From: Andrew Bernard <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] State and Maybe and monad transformers
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Greetings All,

I am writing code using a BankersDequeue from Data.Dequeue. I?d like to wrap 
the push and pop operations in a state monad for the standard reason, to avoid 
passing the dequeue around between function calls, and regard it as state 
instead, which it is. Wishing to avoid throwing a runtime error if the queue is 
empty (for the general case of queues) I have written a reduction of the 
concept using a crude stack to experiment, which uses State and Maybe. I notice 
that there are very few examples of using State and Maybe together. My 
questions are: Is this a faulty design pattern? Should this be done with monad 
transformers? Are there examples to be found of using State with Maybe as a 
monad transformer combination? Why is this pattern relatively rare, it seems? 
Is this program on the right track?

Andrew

? snip

module Main where

import Control.Monad.State

type Stack = [Int]

popIt :: Stack -> (Maybe Int, Stack)
popIt [] = (Nothing, [])
popIt (x:xs) = (Just x, xs)
               
pop :: State Stack (Maybe Int)
pop = state popIt

push :: Int -> State Stack (Maybe ())
push a = state $ \xs -> (Just (), a:xs)

main = do
  let a = evalState (do
                     push 3
                     push 2
                     push 1
                     pop
                     pop
                     a <- pop
                     return a
                   ) []
  print a
         
? snip

  



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

Message: 3
Date: Tue, 29 Sep 2015 01:15:04 +1000
From: Andrew Bernard <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Haskell package maturity
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Since starting to look on Hackage for packages for such vital things as queues 
and algorithms, I am surprised to see very low numbers of downloads for 
packages that seem to me to be vitally important. For example, queuelike has 
only been downloaded 1617 times since being uploaded in 2009. Similar very low 
numbers seem to apply for many packages. Another example is cubicspline with 
only 485 downloads.

My question is, are the numbers on Hackage correct, and if so, do they indicate 
hardly anybody uses them, or indeed Haskell? I am starting to wonder.

I also notice version numbers are very low, often less than one and most often 
around 0.1 or so. This is either a display of extreme modesty on the part of 
Haskell library code developers (in fact, often found in open source 
communities), or an indication of lack of maturity of the code. Overall I am 
puzzled about this. I am trying to establish what packages to use in my coding 
and there seems to be little indication of what to choose, and how to assess 
code maturity. What am I missing?

Andrew


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150929/270ea815/attachment-0001.html>

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

Message: 4
Date: Wed, 30 Sep 2015 05:44:05 +0000
From: Ben Kolera <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] State and Maybe and monad
        transformers
Message-ID:
        <CAPmqrp91==f3r7oukhadgy-k_0tsq6gxmvbsppenifsfla9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Andrew,

It looks like you're quickly going to hit a point where MaybeT is helpful
to you.

https://hackage.haskell.org/package/transformers-0.4.3.0/docs/Control-Monad-Trans-Maybe.html


This gives you a trick to ignore the fact that you're getting a maybe and
make MaybeT terminate the computation early if there was nothing on the
stack to make further computations with.

It will involve making the leap from simple monads to transformers though,
which can be tricky but is worthwhile in the long run.

There is a fairly succinct explanation of all of this, here:

https://wiki.haskell.org/Monad_Transformers_Tutorial

It's just based on IO rather than State, but that makes little difference
to the concept.

Typing this out in a rush at work, so apologies in advance if this doesn't
make any sense. ;)

Cheers,
Ben

On Wed, 30 Sep 2015 at 14:22 Andrew Bernard <[email protected]>
wrote:

> Greetings All,
>
> I am writing code using a BankersDequeue from Data.Dequeue. I?d like to
> wrap the push and pop operations in a state monad for the standard reason,
> to avoid passing the dequeue around between function calls, and regard it
> as state instead, which it is. Wishing to avoid throwing a runtime error if
> the queue is empty (for the general case of queues) I have written a
> reduction of the concept using a crude stack to experiment, which uses
> State and Maybe. I notice that there are very few examples of using State
> and Maybe together. My questions are: Is this a faulty design pattern?
> Should this be done with monad transformers? Are there examples to be found
> of using State with Maybe as a monad transformer combination? Why is this
> pattern relatively rare, it seems? Is this program on the right track?
>
> Andrew
>
> ? snip
>
> module Main where
>
> import Control.Monad.State
>
> type Stack = [Int]
>
> popIt :: Stack -> (Maybe Int, Stack)
> popIt [] = (Nothing, [])
> popIt (x:xs) = (Just x, xs)
>
> pop :: State Stack (Maybe Int)
> pop = state popIt
>
> push :: Int -> State Stack (Maybe ())
> push a = state $ \xs -> (Just (), a:xs)
>
> main = do
>   let a = evalState (do
>                      push 3
>                      push 2
>                      push 1
>                      pop
>                      pop
>                      a <- pop
>                      return a
>                    ) []
>   print a
>
> ? snip
>
>
>
> _______________________________________________
> 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/20150930/9c644bf5/attachment-0001.html>

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

Message: 5
Date: Wed, 30 Sep 2015 11:22:18 +0100
From: emacstheviking <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell package maturity
Message-ID:
        <CAEiEuUKz3T0oreia7pk1_Oh8iq72H9oGXiZM99=UeKd=bpo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Andrew,

The sheer number of packages is overwhelming and you can spend a very long
time indeed trying to find something "suitable"... which... eventually may
lead one to the conclusion, "It'll be quicker to roll my own" and then
"Hey, I will upload it to Hackage, someone else might like it"... and so
the list grows and grows and what began as an altruistic thought serves
only to make it harder for the next guy to "find a suitable package".

Personally, I've walked away from Haskell purely because I got fed up being
continually bitten by "cabal hell".
It's a shame because apart from LISP no other language has had such an
impact on my thinking.

I did find that whatever package I used though, they tend to work, so maybe
take the first one and get on with it, that's what I used to do.

Hope that helped, it probably didn't.
All the best,
Sean Charles.


On 28 September 2015 at 16:15, Andrew Bernard <[email protected]>
wrote:

> Since starting to look on Hackage for packages for such vital things as
> queues and algorithms, I am surprised to see very low numbers of downloads
> for packages that seem to me to be vitally important. For example,
> queuelike has only been downloaded 1617 times since being uploaded in 2009.
> Similar very low numbers seem to apply for many packages. Another example
> is cubicspline with only 485 downloads.
>
> My question is, are the numbers on Hackage correct, and if so, do they
> indicate hardly anybody uses them, or indeed Haskell? I am starting to
> wonder.
>
> I also notice version numbers are very low, often less than one and most
> often around 0.1 or so. This is either a display of extreme modesty on the
> part of Haskell library code developers (in fact, often found in open
> source communities), or an indication of lack of maturity of the code.
> Overall I am puzzled about this. I am trying to establish what packages to
> use in my coding and there seems to be little indication of what to choose,
> and how to assess code maturity. What am I missing?
>
> Andrew
>
>
> _______________________________________________
> 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/20150930/de1683bb/attachment.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 87, Issue 21
*****************************************

Reply via email to