Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1.  Rekommendation for select i GUI (Anders Persson)
   2. Re:  Ignoring the result of a monadic computation (Brent Yorgey)
   3. Re:  Ignoring the result of a monadic computation
      (Tim Baumgartner)
   4. Re:  Ignoring the result of a monadic computation (Brent Yorgey)
   5. Re:  Rekommendation for select i GUI (Bastian Erdn??)
   6. Re:  Ignoring the result of a monadic computation (Bastian Erdn??)
   7.  Re: Ignoring the result of a monadic computation
      (Ertugrul Soeylemez)
   8. Re:  Re: Ignoring the result of a monadic computation
      (Tim Baumgartner)


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

Message: 1
Date: Fri, 19 Nov 2010 19:03:43 +0100
From: Anders Persson <anders.u.pers...@gmail.com>
Subject: [Haskell-beginners] Rekommendation for select i GUI
To: beginners@haskell.org
Message-ID: <4ce6bbff.7080...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi!
i have installed Haskell Platform om a Windows Vista,
I will also run Haskell on a OS/X machine.

I have looked at a good GUI tool,  tested wxHaskell,
and hs2GTK but no one seems easy to be install,
lot off errors, etc...

Have i missed something and could i get some comments om
a GUI toolkit to select.

Best regards
Anders


-- 

med vänliga hälsningar
Anders
______________________________________________
Anders Persson
anders.u.pers...@gmail.com



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

Message: 2
Date: Fri, 19 Nov 2010 14:20:41 -0500
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID: <20101119192041.ga4...@seas.upenn.edu>
Content-Type: text/plain; charset=iso-8859-1

On Fri, Nov 19, 2010 at 03:37:10PM +0000, Magnus Therning wrote:
> On Fri, Nov 19, 2010 at 15:31, Brent Yorgey <byor...@seas.upenn.edu> wrote:
> > On Fri, Nov 19, 2010 at 03:26:04PM +0000, Magnus Therning wrote:
> >> On Fri, Nov 19, 2010 at 15:21, Brent Yorgey <byor...@seas.upenn.edu> wrote:
> >> > On Fri, Nov 19, 2010 at 07:56:02AM +0100, Tim Baumgartner wrote:
> >> >> Hi,
> >> >>
> >> >> while learning about monads, I had something like
> >> >>
> >> >> do
> >> >>    line <- getLine
> >> >>    something
> >> >>    putStrLn line
> >> >>
> >> >> and I wondered if I could write it in one line, without naming of 
> >> >> parameters.
> >> >> I finally came up with
> >> >>
> >> >> getLine >>= ignore something >>= putStrLn
> >> >>
> >> >> using
> >> >> ignore :: Monad m => m a -> b -> m b
> >> >> ignore m a = m >> return a
> >> >>
> >> >> I'm satisfied with this solution but searching hoogle I didn't find
> >> >> a standard function for my ignore. Am I missing something?
> >> >
> >> > Nope, there isn't such a function, but I like it.  It reminds me of
> >> > (*>) and (<*) from Control.Applicative.  Note that you sometimes see
> >> > the name 'ignore' used for a slightly different function, namely
> >> >
> >> >  ignore :: Monad m => m a -> m ()
> >> >  ignore m = m >> return ()
> >> >
> >> > but yours is a bit more general.  Other names for your function might
> >> > be 'passThrough' or something like that.
> >>
> >> I'm not sure I see any benefit of ': m a -> b -> m b' over 'm a -> m
> >> ()'.  When would you want to use the former?
> >
> > >From the OP's message:
> >
> >  getLine >>= ignore something >>= putStrLn
> >
> > which executes 'something' for its side effect and passes the result
> > of getLine through to putStrLn, without ever having to give a name to
> > the result of getLine.  IIUC this was the whole point.
> 
> IMNSHO, not such a strong argument for such a function though. :-)

It depends what the "argument" is about.  I agree there is not a
strong argument for including such a function in the standard
libraries.  But it's a perfectly nice function to define and use in
one's own code.  Haskell makes this sort of abstraction very cheap.

-Brent


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

Message: 3
Date: Fri, 19 Nov 2010 20:39:44 +0100
From: "Tim Baumgartner" <jongleur0...@gmx.de>
Subject: Re: [Haskell-beginners] Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID: <20101119193944.326...@gmx.net>
Content-Type: text/plain; charset="utf-8"

Hi Haskellers,

this was my first post and I'm thankful and really impressed how many qualified 
answers I got. I've been learning Haskell only for a short time but I'm really 
fascinated how mathematical and expressive a programming language can be (I 
usually code Java). Recently I read a blog post, with a function

map (length &&& head) . group

that was much shorter and more elegant than the corresponding Python code. That 
was the main reason for me to try to write my own code in a single line without 
any lambda expressions.

Regards
Tim


-------- Original-Nachricht --------
> Datum: Fri, 19 Nov 2010 07:56:02 +0100
> Von: "Tim Baumgartner" <jongleur0...@gmx.de>
> An: beginners@haskell.org
> Betreff: [Haskell-beginners] Ignoring the result of a monadic computation

> Hi,
> 
> while learning about monads, I had something like
> 
> do
>    line <- getLine
>    something
>    putStrLn line
> 
> and I wondered if I could write it in one line, without naming of
> parameters.
> I finally came up with
> 
> getLine >>= ignore something >>= putStrLn
> 
> using
> ignore :: Monad m => m a -> b -> m b
> ignore m a = m >> return a
> 
> I'm satisfied with this solution but searching hoogle I didn't find a
> standard function for my ignore. Am I missing something?
> 
> Cheers,
> Tim
> -- 
> GRATIS! Movie-FLAT mit über 300 Videos. 
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

-- 
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome


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

Message: 4
Date: Fri, 19 Nov 2010 15:02:57 -0500
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID: <20101119200257.ga5...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Fri, Nov 19, 2010 at 08:39:44PM +0100, Tim Baumgartner wrote:
> Hi Haskellers,
> 
> this was my first post and I'm thankful and really impressed how
> many qualified answers I got. I've been learning Haskell only for a
> short time but I'm really fascinated how mathematical and expressive
> a programming language can be (I usually code Java). Recently I read
> a blog post, with a function
> 
> map (length &&& head) . group
> 
> that was much shorter and more elegant than the corresponding Python
> code. That was the main reason for me to try to write my own code in
> a single line without any lambda expressions.

Indeed!  Writing code without lambda expressions or mentioning
parameters is called "point-free style" (since parameters are
sometimes referred to in the mathematical literature as "points").
For example,

  foo y = bar (baz (frob y))

can be rewritten as

  foo = bar . baz . frob

which is (in most people's opinion) much nicer.  Lambdabot (in the
#haskell IRC channel on freenode.org) has a @pl command for performing
such point-free simplifications.  Point-free style should be taken in
moderation, since it can be taken to unreadably esoteric extremes, but
you are not in danger yet of crossing that line. =)

-Brent


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

Message: 5
Date: Fri, 19 Nov 2010 21:46:27 +0100
From: Bastian Erdn?? <earth...@web.de>
Subject: Re: [Haskell-beginners] Rekommendation for select i GUI
To: anders.u.pers...@gmail.com
Cc: beginners@haskell.org
Message-ID: <b6bdb813-3f05-4b7b-846a-9f18fc6b7...@web.de>
Content-Type: text/plain; charset=us-ascii


On Nov 19, 2010, at 19:03, Anders Persson wrote:

> Hi!
> i have installed Haskell Platform om a Windows Vista,
> I will also run Haskell on a OS/X machine.
> 
> I have looked at a good GUI tool,  tested wxHaskell,
> and hs2GTK but no one seems easy to be install,
> lot off errors, etc...
> 
> Have i missed something and could i get some comments om
> a GUI toolkit to select.

I personally tend to use wxHaskell on OS X as described here[1].

I read that wxHaskell isn't under active development anymore
(not sure that's true) and I also have the impression gtk2hs
is the best developed UI framework for Haskell so far.

If you use gtk2hs you might also want to use gtk-osx[2].  You
could also try qtHaskell[3].  But somehow I didn't like the two
very much.

I also tried HTk[4] once and thought it's quite OK.  But I don't
know if it's major enough to develop a bigger project with it.

[1] http://www.haskell.org/haskellwiki/WxHaskell/MacOS_X
[2] http://gtk-osx.sourceforge.net/
[3] http://qthaskell.berlios.de/
[4] http://www.informatik.uni-bremen.de/htk/

Cheers,
Bastian


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

Message: 6
Date: Fri, 19 Nov 2010 23:31:28 +0100
From: Bastian Erdn?? <earth...@web.de>
Subject: Re: [Haskell-beginners] Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID: <294abcd3-db89-4d6c-a7a9-b2cfa4c50...@web.de>
Content-Type: text/plain; charset=us-ascii


On Nov 19, 2010, at 7:56, Tim Baumgartner wrote:

> Hi,
> 
> while learning about monads, I had something like
> 
> do
>   line <- getLine
>   something
>   putStrLn line
> 
> and I wondered if I could write it in one line, without naming of parameters.
> I finally came up with
> 
> getLine >>= ignore something >>= putStrLn
> 
> using
> ignore :: Monad m => m a -> b -> m b
> ignore m a = m >> return a
> 
> I'm satisfied with this solution but searching hoogle I didn't find a 
> standard function for my ignore. Am I missing something?

I don't know if this is better, but you could also write

  getLine >>= (something >>) . putStrLn

Cheers,
Bastian

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

Message: 7
Date: Sat, 20 Nov 2010 01:58:24 +0100
From: Ertugrul Soeylemez <e...@ertes.de>
Subject: [Haskell-beginners] Re: Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID: <20101120015824.788c9...@tritium.streitmacht.eu>
Content-Type: text/plain; charset=US-ASCII

"Tim Baumgartner" <jongleur0...@gmx.de> wrote:

> while learning about monads, I had something like
>
> do
>    line <- getLine
>    something
>    putStrLn line
>
> and I wondered if I could write it in one line, without naming of
> parameters.  I finally came up with
>
> getLine >>= ignore something >>= putStrLn
>
> using
> ignore :: Monad m => m a -> b -> m b
> ignore m a = m >> return a
>
> I'm satisfied with this solution but searching hoogle I didn't find a
> standard function for my ignore. Am I missing something?

Importing Control.Applicative, you can do this:

  getLine <* something >>= putStrLn

The (<*) function has the following signature:

  (<*) :: (Applicative f) => f a -> f b -> f a

It sequences the two computations in order, but returns the result of
the first.  This is mostly useful in applicative parsers, where you
often need to skip unimportant stuff like spacing and use an earlier
result.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/




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

Message: 8
Date: Sat, 20 Nov 2010 09:18:48 +0100
From: Tim Baumgartner <baumgartner....@googlemail.com>
Subject: Re: [Haskell-beginners] Re: Ignoring the result of a monadic
        computation
To: beginners@haskell.org
Message-ID:
        <aanlktimw1wq4xggdi8yfpboevagpo-fqgleoncxe7...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2010/11/20 Ertugrul Soeylemez <e...@ertes.de>:
> Importing Control.Applicative, you can do this:
>
>  getLine <* something >>= putStrLn

That's exactly what I was looking for. And indeed I wanted to consume
some whitespace in a parser, just like you said. So I will start to
read about Control.Applicative in Brent's Typeclassopedia soon.

Thanks a lot
Tim


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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 29, Issue 29
*****************************************

Reply via email to