Send Beginners mailing list submissions to
[email protected]
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
[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: GUI library (Tim Perry)
2. Re: GUI library (Emanuel Koczwara)
3. Re: Hackages that only depend on Haskell Platform (Darren Grant)
4. How do I perform things inside a Monad? (Martin Drautzburg)
5. Re: How do I perform things inside a Monad? (Brent Yorgey)
6. Re: How do I perform things inside a Monad? (Martin Drautzburg)
7. Re: Can someone help to unnest this "do" cascade
(Henk-Jan van Tuyl)
8. interface/abstract class: what is the haskell way?
(Emmanuel Touzery)
----------------------------------------------------------------------
Message: 1
Date: Thu, 7 Feb 2013 11:04:06 -0800
From: Tim Perry <[email protected]>
Subject: Re: [Haskell-beginners] GUI library
To: The Haskell-Beginners Mailing List - Discussion of
primarilybeginner-level topics related to Haskell
<[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of
primarilybeginner-level topics related to Haskell
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Are you kidding? Swing is a dream. Ever spent time with MFC? Get real
On Feb 7, 2013, at 10:59 AM, Brandon Allbery <[email protected]> wrote:
> On Thu, Feb 7, 2013 at 1:46 PM, Tim Perry <[email protected]> wrote:
> Java did it. Swing just asks the OS for a window and draws in it. Works
> fairly well...except that a Java (Swing)
>
> It did indeed. I can tell you've not spent much time with the folks who have
> to deal with the result. AWT/Swing is exhibit A for why nobody else does it
> that way.
>
> --
> brandon s allbery kf8nh sine nomine associates
> [email protected] [email protected]
> unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130207/2531cc24/attachment-0001.htm>
------------------------------
Message: 2
Date: Thu, 07 Feb 2013 20:04:17 +0100
From: Emanuel Koczwara <[email protected]>
Subject: Re: [Haskell-beginners] GUI library
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID: <1360263857.2852.6.camel@emanuel-Dell-System-Vostro-3750>
Content-Type: text/plain; charset="UTF-8"
Hi,
Dnia 2013-02-07, czw o godzinie 13:59 -0500, Brandon Allbery pisze:
> On Thu, Feb 7, 2013 at 1:46 PM, Tim Perry <[email protected]> wrote:
> Java did it. Swing just asks the OS for a window and draws in
> it. Works fairly well...except that a Java (Swing)
>
>
> It did indeed. I can tell you've not spent much time with the folks
> who have to deal with the result. AWT/Swing is exhibit A for why
> nobody else does it that way.
And what about QML?
Emanuel
------------------------------
Message: 3
Date: Thu, 7 Feb 2013 12:02:08 -0800
From: Darren Grant <[email protected]>
Subject: Re: [Haskell-beginners] Hackages that only depend on Haskell
Platform
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<ca+jd6sju3ppxsprv7sqwhqynsvexvcbj1yk_ls8udnjx701...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
That's a good reference, but what I am exploring is a quick, draconian
solution that will give me an extremely conservative set of packages that
are not interdependent in any way.
It seems that such a program does not yet exist, but should be
straightforward to write, joining HackageDB dependencies against packages
in the platform. The best I've got so far is to scrape results from cabal
info, but I'm looking for a more efficient set of API's to solve the
problem. Does the Haskell Platform come with modules that support this sort
of API?
Cheers,
d
On Thu, Feb 7, 2013 at 4:53 AM, Richard Norton <[email protected]> wrote:
> On Feb 7, 2013, at 12:37 AM, Darren Grant <[email protected]> wrote:
>
> > Is there a list of hackages available that *only* depend on the latest
> > Haskell Platform?
> >
> > -or-
> >
> > Can such a list be reasonably generated?
> >
> > -or-
> >
> > Will there even be anything left after the hackages are filtered?
>
> This project seems related:
>
> https://github.com/fpco/stackage
>
> Richard
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130207/7010e7f0/attachment-0001.htm>
------------------------------
Message: 4
Date: Thu, 7 Feb 2013 23:07:57 +0100
From: Martin Drautzburg <[email protected]>
Subject: [Haskell-beginners] How do I perform things inside a Monad?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Hello all,
In the ALSA Midi package, there is an example, where he first sets up client,
port, queue and stuff. All of these are IO actions, and there are a number of
nested "do"s. Then in the innermost "do" he has all the pieces together and
starts playing. In this case the actual "song" is coded in the innermost do.
My question is: how can I inject a song from outside. Of course I could make
it another parameter, which would have to travel through all the "do"s, but I
already have more than enough parameters.
Then I tried fmap. But the actual playing is an IO operation itself, so I
cannot write a pure function and fmap it over the Monad.
Any ideas?
--
Martin
------------------------------
Message: 5
Date: Thu, 7 Feb 2013 17:25:32 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] How do I perform things inside a
Monad?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Thu, Feb 07, 2013 at 11:07:57PM +0100, Martin Drautzburg wrote:
> Hello all,
>
> In the ALSA Midi package, there is an example, where he first sets up client,
> port, queue and stuff. All of these are IO actions, and there are a number of
> nested "do"s. Then in the innermost "do" he has all the pieces together and
> starts playing. In this case the actual "song" is coded in the innermost do.
>
> My question is: how can I inject a song from outside. Of course I could make
> it another parameter, which would have to travel through all the "do"s, but I
> already have more than enough parameters.
Just make it a parameter. If it is in scope, you can use it in the
innermost 'do'. I'm not sure what you mean by "travel through all the
"do"s". You don't have to do anything special to make this happen.
Like so:
foo bar baz = do
withFoo $ \foo -> do
blub
withOtherThing $ \thing -> do
blah
something bar baz
Notice how 'bar' and 'baz' are automatically in scope throughout the
whole thing, even the innermost do.
-Brent
------------------------------
Message: 6
Date: Fri, 8 Feb 2013 07:18:38 +0100
From: Martin Drautzburg <[email protected]>
Subject: Re: [Haskell-beginners] How do I perform things inside a
Monad?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="iso-8859-1"
On Thursday, 7. February 2013 23:25:32 Brent Yorgey wrote:
> On Thu, Feb 07, 2013 at 11:07:57PM +0100, Martin Drautzburg wrote:
> > Hello all,
> >
> > In the ALSA Midi package, there is an example, where he first sets up
> > client, port, queue and stuff. All of these are IO actions, and there
> > are a number of nested "do"s. Then in the innermost "do" he has all the
> > pieces together and starts playing. In this case the actual "song" is
> > coded in the innermost do.
> >
> > My question is: how can I inject a song from outside. Of course I could
> > make it another parameter, which would have to travel through all the
> > "do"s, but I already have more than enough parameters.
>
> Just make it a parameter. If it is in scope, you can use it in the
> innermost 'do'. I'm not sure what you mean by "travel through all the
> "do"s". You don't have to do anything special to make this happen.
> Like so:
>
>
> foo bar baz = do
> withFoo $ \foo -> do
> blub
> withOtherThing $ \thing -> do
> blah
> something bar baz
>
> Notice how 'bar' and 'baz' are automatically in scope throughout the
> whole thing, even the innermost do.
The original code was written exactly in this style. Is this "$ \foo ->do"
cascade some kind of idiom?
The thing is, I tried to split this monster up into several functions. For
this, my functions got quite a number of parameters. Passing bar baz to the
toplevel function would add even more parameters.
I understand why your suggestion works without "tramp" parameters.
But somehow I don't like "$ \foo ->do" cascades. It looks ugly and I do not
fully understand the pattern and when and why it is needed. If there are
situations which require three nested "do"s, then there might be situations
which require 1000 nested "do"s. It just won't scale.
--
Martin
------------------------------
Message: 7
Date: Fri, 08 Feb 2013 08:26:38 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] Can someone help to unnest this "do"
cascade
To: [email protected], "Martin Drautzburg"
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Wed, 06 Feb 2013 22:31:05 +0100, Martin Drautzburg
<[email protected]> wrote:
> Can
> someone please walk me through it and possibly show ways to avoid the
> massive
> nesting.
>
> dtz = do
> SndSeq.withDefault SndSeq.Block $ \h -> do
> Client.setName (h :: SndSeq.T SndSeq.DuplexMode) "Haskell-Melody"
> Port.withSimple h "out"
> (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite])
> (Port.types [Port.typeMidiGeneric, Port.typeApplication]) $ \p
> -> do
> Queue.with h $ \q -> do
> c <- Client.getId h
> let me = Addr.Cons c p
> conn <- parseDestArgs h me ["20:0"]
> Queue.control h q Event.QueueStart Nothing
> Queue.control h q (Event.QueueTempo (Event.Tempo
> 10000000)) Nothing
> return ()
I like to divide large functions into several smaller ones:
dtz =
SndSeq.withDefault SndSeq.Block f1
where
f1 h =
do
Client.setName (h :: SndSeq.T SndSeq.DuplexMode) "Haskell-Melody"
Port.withSimple h "out"
(Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite])
(Port.types [Port.typeMidiGeneric, Port.typeApplication]) (f2
h)
f2 h p = Queue.with h (f3 h p)
f3 h p q =
do
c <- Client.getId h
let me = Addr.Cons c p
conn <- parseDestArgs h me ["20:0"]
Queue.control h q Event.QueueStart Nothing
Queue.control h q (Event.QueueTempo (Event.Tempo 10000000))
Nothing
return ()
f1, f2 and f3 might be replaced with more meaningful names. The "return
()" at the end can be removed; such things can be found with hlint[0].
Regards,
Henk-Jan van Tuyl
[0] http://hackage.haskell.org/package/hlint
--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
------------------------------
Message: 8
Date: Fri, 8 Feb 2013 10:50:30 +0100
From: Emmanuel Touzery <[email protected]>
Subject: [Haskell-beginners] interface/abstract class: what is the
haskell way?
To: "[email protected]" <[email protected]>
Message-ID:
<CAC42RemzdcMe57wz_1kKKAfHhcygP6KWnetrsWdj7=iymnc...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hello,
i wrote two programs in haskell which have the same problem: they define a
common datatype (let's say Event for instance), and they have several
modules, each one importing a list of Event from a specific data source.
So all these modules have a similar api:
getEvents :: <params> -> IO [Event]
And maybe a couple extra functions, more or less the same for each module.
In OO, I would make a base class, like EventProvider, with a couple
abstract methods and in the main class of my app, I would have a list of
EventProvider and loop over them. That way to add a new EventProvider, I
would just add the import and an element in that list.
Currently in haskell I duplicate the function calls for each provider. And
because there is no interface constraint, each module has a slightly
different API.
The "obvious" way to do in haskell what I would do in OO would be through
type classes. However I realize type classes are not quite interfaces. I'm
wondering what would be the "haskell way" to solve this problem?
For sure type classes do the job. But is it the idiomatic way of solving
this problem?
Thank you!
Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130208/e1b0b746/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 56, Issue 14
*****************************************