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.  Re: WinGHCi (Benjamin L. Russell)
   2. Re:  lazy database queries (Michael Hendricks)
   3.  Re: Is haskell a good choice for someone,        who  never
      programmed before? (Benjamin L. Russell)
   4. Re:  lazy database queries (Brent Yorgey)
   5.  Monad transformers and MonadPlus (Johann Bach)
   6. Re:  Monad transformers and MonadPlus (Brent Yorgey)
   7. Re:  Monad transformers and MonadPlus (Antoine Latter)


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

Message: 1
Date: Fri, 30 Jul 2010 07:11:14 +0900
From: dekudekup...@yahoo.com (Benjamin L. Russell)
Subject: [Haskell-beginners] Re: WinGHCi
To: beginners@haskell.org
Message-ID: <m2d3u6lz0d....@yahoo.com>
Content-Type: text/plain; charset=us-ascii

Michael Mossey <m...@alumni.caltech.edu> writes:

> What is special about WinGHCi? Does it add anything to ghci or  is it
> just a GUI interface to ghci commands? I have RSI and avoid the mouse,
> so I would rather use ghci unless WinGHCi adds something special.

AFAIK, WinGHCi is just a GUI for GHCi on Windows.

Basically, WinGHCi:GHCi::WinHugs:Hugs.

Some additional features listed under "WinGhciFeatures - winghci -
Project Hosting on Google Code" (see
http://code.google.com/p/winghci/wiki/WinGhciFeatures) are the
following:

> One extension with respect to GHCI options is that you can use the &
> character as a prefix when setting your editor, so that when you invoke
> the :edit command, GHCI will not block until you close your editor. 

> You
> can also set additional command line parameters to GHCI through the GHCI
> Startup entry. Note that this will restart the interpreter. Please, do
> no use "ghci.exe" in your startup command but use "ghc.exe
> --interactive" instead. All options are recorded in the windows registry
> and are kept among different sessions.

> A history of issued commands is kept by WinGhci. This history is also
> recorded in the registry, so that it is also kept among sessions. You
> can move through your command history by using the UP and DOWN
> keys. Additionally, you can search in your history. Simply type a text
> and press TAB repeatedly to search all previous commands containing that
> text. You can also clear the current command by pressing ESC. 

Hope this helps.

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ 



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

Message: 2
Date: Thu, 29 Jul 2010 16:24:57 -0600
From: Michael Hendricks <mich...@ndrix.org>
Subject: Re: [Haskell-beginners] lazy database queries
To: Gabr?el A. P?tursson <gabri...@simnet.is>
Cc: beginners@haskell.org
Message-ID: <20100729222457.ga3...@ginosko.ndrix.org>
Content-Type: text/plain; charset=iso-8859-1

Thanks Gabríel.  That's exactly what I was looking for.  I had avoided
the docs for System.IO.Unsafe since "unsafe" scared me away :-)

I've cc'd the list so that others can find your excellent answer in
the archives later.

-- 
Michael

On Thu, Jul 29, 2010 at 03:32:25PM +0000, "Gabríel A. Pétursson" wrote:
>  You might be interested in unsafeInterleaveIO in the module
> System.IO.Unsafe
> <http://users.skynet.be/jyp/html/base/System-IO-Unsafe.html>.
> 
> On 29.07.2010 14:04, Michael Hendricks wrote:
> >I have a data structure roughly like
> >
> >     data Prices = Prices {
> >         today    :: [Price],
> >         thisYear :: [Price]
> >     }
> >
> >Both today and thisYear are initially populated by database queries
> >using HDBC.  I then have functions which call today and possibly call
> >thisYear.  thisYear is not called often and the query to retrieve that
> >data is very expensive.
> >
> >I thought I could use HDBC's laziness to postpone actually running the
> >slow query until thisYear was required.  Attempts with quickQuery
> >suggest that the query is executed immediately and the only laziness
> >is with fetching the results.
> >
> >Is it possible to make thisYear a lazy list which only executes the
> >query if thisYear's values are required?
> >
> >Thank you.


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

Message: 3
Date: Fri, 30 Jul 2010 08:10:51 +0900
From: dekudekup...@yahoo.com (Benjamin L. Russell)
Subject: [Haskell-beginners] Re: Is haskell a good choice for someone,
        who  never programmed before?
To: beginners@haskell.org
Message-ID: <m27hkdnatg....@yahoo.com>
Content-Type: text/plain; charset=us-ascii

Jorden M <jrm8...@gmail.com> writes:

> Reading The Haskell Road to Logic, Maths, and Programming would be a
> great way for someone with no more than high school level math to get
> started with programming and higher mathematics.

Another title that I would recommend is _Programming in Haskell_, by
Graham Hutton [1].  This book is written for beginners, and requires no
previous programming experience.  A favorable review [2] of this title
has been written by Duncan Coutts.

-- Benjamin L. Russell

[1] Hutton, Graham. _Programming in Haskell._ Cambridge: Cambridge
University Press, 2007. <http://www.cs.nott.ac.uk/~gmh/book.html>.

[2] Coutts, Duncan. "Book Review: 'Programming in Haskell' by Graham
Hutton." _The Monad.Reader Issue 7_ (2007): 35-44. Web. 30
Jul. 2010. <http://www.cs.nott.ac.uk/~gmh/book-review.pdf>.



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

Message: 4
Date: Fri, 30 Jul 2010 07:13:24 +0100
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] lazy database queries
To: beginners@haskell.org
Message-ID: <20100730061323.ga10...@seas.upenn.edu>
Content-Type: text/plain; charset=iso-8859-1

On Thu, Jul 29, 2010 at 04:24:57PM -0600, Michael Hendricks wrote:
> Thanks Gabríel.  That's exactly what I was looking for.  I had avoided
> the docs for System.IO.Unsafe since "unsafe" scared me away :-)

That's exactly what the "unsafe" is there for! =)

The reason this particular idea is unsafe (one reason, at least,
others might know of more) is that the database might change (or
disapppear, or...) in the middle of lazily reading from it, so your
program gets an inconsistent view of the world.  I'm not trying to
discourage you, just making sure you understand the risks.  If you are
sure the database won't change (or you don't care if it does) then
this should work great.

-Brent

> 
> I've cc'd the list so that others can find your excellent answer in
> the archives later.
> 
> -- 
> Michael
> 
> On Thu, Jul 29, 2010 at 03:32:25PM +0000, "Gabríel A. Pétursson" wrote:
> >  You might be interested in unsafeInterleaveIO in the module
> > System.IO.Unsafe
> > <http://users.skynet.be/jyp/html/base/System-IO-Unsafe.html>.
> > 
> > On 29.07.2010 14:04, Michael Hendricks wrote:
> > >I have a data structure roughly like
> > >
> > >     data Prices = Prices {
> > >         today    :: [Price],
> > >         thisYear :: [Price]
> > >     }
> > >
> > >Both today and thisYear are initially populated by database queries
> > >using HDBC.  I then have functions which call today and possibly call
> > >thisYear.  thisYear is not called often and the query to retrieve that
> > >data is very expensive.
> > >
> > >I thought I could use HDBC's laziness to postpone actually running the
> > >slow query until thisYear was required.  Attempts with quickQuery
> > >suggest that the query is executed immediately and the only laziness
> > >is with fetching the results.
> > >
> > >Is it possible to make thisYear a lazy list which only executes the
> > >query if thisYear's values are required?
> > >
> > >Thank you.
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


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

Message: 5
Date: Fri, 30 Jul 2010 03:08:44 -0700
From: Johann Bach <johann.bach1...@gmail.com>
Subject: [Haskell-beginners] Monad transformers and MonadPlus
To: beginners <beginners@haskell.org>
Message-ID:
        <aanlktikz7ndqvz0xewasvmjsuvhf3wkahncs1_e=j...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

This interesting page in Wikibooks describes how to write MaybeT:

http://en.wikibooks.org/wiki/Haskell/Monad_transformers

And it makes MaybeT an instance of MonadPlus. Even when used with IO
as the inner monad.

the constraint on the inner monad is Monad, not Monad plus:

  instance (Monad m) => MonadPlus (MaybeT m) where

Apparently IO is not normally an instance of MonadPlus. It is
interesting to be able to combine IO operations with mplus, because
the idea of "trying computations until one succeeds" is so common in
IO.

Then I started wondering if StateT or ErrorT could be used to make IO
the inner monad of a MonadPlus instance. Well, StateT is an instance
of MonadPlus but with a MonadPlus constraint on the inner monad, so IO
won't cut it.

This leads me to wonder if there is a way to write mplus and mzero in
StateT or ErrorT without a MonadPlus constraint on the inner monad.
But if not, what was special about MaybeT as described in Wikibooks?


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

Message: 6
Date: Fri, 30 Jul 2010 11:48:13 +0100
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Monad transformers and MonadPlus
To: beginners@haskell.org
Message-ID: <20100730104813.ga5...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Fri, Jul 30, 2010 at 03:08:44AM -0700, Johann Bach wrote:
> This interesting page in Wikibooks describes how to write MaybeT:
> 
> http://en.wikibooks.org/wiki/Haskell/Monad_transformers
> 
> And it makes MaybeT an instance of MonadPlus. Even when used with IO
> as the inner monad.
> 
> the constraint on the inner monad is Monad, not Monad plus:
> 
>   instance (Monad m) => MonadPlus (MaybeT m) where
> 
> Apparently IO is not normally an instance of MonadPlus. It is
> interesting to be able to combine IO operations with mplus, because
> the idea of "trying computations until one succeeds" is so common in
> IO.
> 
> Then I started wondering if StateT or ErrorT could be used to make IO
> the inner monad of a MonadPlus instance. Well, StateT is an instance
> of MonadPlus but with a MonadPlus constraint on the inner monad, so IO
> won't cut it.
> 
> This leads me to wonder if there is a way to write mplus and mzero in
> StateT or ErrorT without a MonadPlus constraint on the inner monad.
> But if not, what was special about MaybeT as described in Wikibooks?

It should be possible to do this with ErrorT, but not with StateT.
The thing that is special about MaybeT (and ErrorT) is that it adds a
notion of failure (and choice), which is exactly what MonadPlus is
about.  A MaybeT IO computation is an IO computation that might fail.
StateT just adds some state -- if we didn't already have a notion of
failure before, we won't get one by adding some state.

-Brent


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

Message: 7
Date: Fri, 30 Jul 2010 06:56:44 -0500
From: Antoine Latter <aslat...@gmail.com>
Subject: Re: [Haskell-beginners] Monad transformers and MonadPlus
To: Johann Bach <johann.bach1...@gmail.com>
Cc: beginners <beginners@haskell.org>
Message-ID:
        <aanlktinaioyavnou1gt5wymuewxlidf9srhswh0g4...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

You could always add a MondPlus instance to IO directly (or a newtype
wrapper).

'mplus' would set up exception handling and 'mzero' would through an
exception. You might want to limit it to a subset of exceptions, though.

Antoine

On Jul 30, 2010 5:09 AM, "Johann Bach" <johann.bach1...@gmail.com> wrote:

This interesting page in Wikibooks describes how to write MaybeT:

http://en.wikibooks.org/wiki/Haskell/Monad_transformers

And it makes MaybeT an instance of MonadPlus. Even when used with IO
as the inner monad.

the constraint on the inner monad is Monad, not Monad plus:

 instance (Monad m) => MonadPlus (MaybeT m) where

Apparently IO is not normally an instance of MonadPlus. It is
interesting to be able to combine IO operations with mplus, because
the idea of "trying computations until one succeeds" is so common in
IO.

Then I started wondering if StateT or ErrorT could be used to make IO
the inner monad of a MonadPlus instance. Well, StateT is an instance
of MonadPlus but with a MonadPlus constraint on the inner monad, so IO
won't cut it.

This leads me to wonder if there is a way to write mplus and mzero in
StateT or ErrorT without a MonadPlus constraint on the inner monad.
But if not, what was special about MaybeT as described in Wikibooks?
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100730/4a115ae5/attachment.html

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

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


End of Beginners Digest, Vol 25, Issue 57
*****************************************

Reply via email to