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. Mutable collection of gui objects (wxHaskell) (Jeffrey Brown)
2. Is there an aeson-like XML serialization library? (Thomas Koster)
3. Re: Arrow vs. function (martin)
4. Are Arrows good for simulation purposes (martin)
5. Re: Is there an aeson-like XML serialization library?
(Michael Snoyman)
6. Re: Mutable collection of gui objects (wxHaskell)
(Henk-Jan van Tuyl)
----------------------------------------------------------------------
Message: 1
Date: Mon, 30 Mar 2015 19:14:35 -0700
From: Jeffrey Brown <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Mutable collection of gui objects
(wxHaskell)
Message-ID:
<CAEc4Ma2WbxWzUnYD4xooOD=vg_itgcrdp-0upvoaxcgknoq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
On Github, Jeremy O'Donoghue provides wx example code. From his collection
I am trying to modify Layout.hs [1] to permit a variable number, rather
than a fixed number, of text entry boxes. I shrank the program, mostly by
removing features, until it was this:
main = start $ do
f <- frame [text := "Layout test"]
p <- panel f []
xinput <- textEntry p [text := "100"]
yinput <- textEntry p [text := "100"]
myVar <- varCreate [xinput,yinput]
set f [ layout := container p $ margin 10 $
column 5 [boxed "coordinates" (grid 5 5
[[hfill $ widget xinput], [hfill $ widget yinput]] -- replacing
) ] ]
return ()
I want to replace the line marked "replacing". Rather than hard-coding the
number of text entry boxes (2), I want it to deal with a mutable collection
of them, in myVar.
I tried this:
[ fmap (\e -> hfill $ widget e) $ varGet myVar ]
and got this error:
Layout.hs:23:11:
Couldn't match type `IO' with `[]'
Expected type: [Layout]
Actual type: IO Layout
In the expression: fmap (\ e -> hfill $ widget e) $ varGet myVar
In the third argument of `grid', namely
`[fmap (\ e -> hfill $ widget e) $ varGet myVar]'
In the second argument of `boxed', namely
`(grid 5 5 [fmap (\ e -> hfill $ widget e) $ varGet myVar])'
So then I tried something I thought would be equivalent:
[[ (hfill $ widget e) | e <- (varGet myVar)]]
and got a different error:
Layout.hs:23:39:
Couldn't match expected type `[w0]'
with actual type `IO [TextCtrl ()]'
In the return type of a call of `varGet'
In the expression: (varGet myVar)
In a stmt of a list comprehension: e <- (varGet myVar)
I kind of understand the problem is that when I varGet myVar, I end up with
type IO Layout, rather than type Layout, but I don't know what to do about
it.
Thanks,
Jeff
[1] https://github.com/jodonoghue/wxHaskell/blob/master/samples/wx/Layout.hs
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150330/b4401c2c/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 31 Mar 2015 14:26:53 +1100
From: Thomas Koster <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Is there an aeson-like XML serialization
library?
Message-ID:
<CAG1wH7DD-XBuhCnNnq=vc5ykghmec0qnycmpp1n7qj8y5b4...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi list,
I want to write a simple XML web service in Haskell that services a .NET
WCF client, but am struggling with choosing the right XML library.
"aeson" [1] has been a pleasure to use, so I am looking for an XML
serialization library similar to aeson, where I can write
ToElement/FromElement instances using simple applicative combinators,
working with a high-level document model (i.e. not a parse tree), just like
I have done in the past with ToJSON/FromJSON.
Does such a library exist?
I need the library to understand XML namespaces and the mandatory
predefined entities, but I do not need any other extensions like XML
Schemas, XPath or XSLT. Preferably, "xmlns" attributes should be handled
specially and namespace prefixes resolved by the parser. "xmlns" attributes
should be placed automatically by the renderer (I don't care what prefixes
it chooses). I do not want to have to keep track of seen namespace prefixes
while I am traversing the document, or to manually place "xmlns" attributes
on elements for rendering. The "xml" [2] library is giving me grief at the
moment with how unspecial its treatment of namespaces is.
HXT appears to be beyond my skill level at the moment. There appear to be
too many new things I would have to learn all at once before I could use it
for this simple task. Cf. aeson, which I was able to use for practical
applications the day I learned what an applicative functor was.
[1] https://hackage.haskell.org/package/aeson
[2] https://hackage.haskell.org/package/xml
Thanks,
--
Thomas Koster
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150331/81e749c7/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 31 Mar 2015 07:22:32 +0200
From: martin <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Arrow vs. function
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252
Am 03/23/2015 um 09:57 PM schrieb John Wiegley:
>>>>>> martin <[email protected]> writes:
>
>> But that's what a function does. So what's the fundamental difference
>> between an arrow and a fuction?
>
> Arrows abstract functions, allowing you to have constructions like Kleisli,
> which are Arrows, but compose in the presence of effects using (<=<) rather
> than (.).
I recall reading something like "under composition an arrow returns a new
version of itself". It this correct? This
would indeed be something a function does not do.
------------------------------
Message: 4
Date: Tue, 31 Mar 2015 07:33:56 +0200
From: martin <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Are Arrows good for simulation purposes
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Hello all,
little do I know about arrows, but the "stream processor" metaphor suggests,
that they can be used to simulate a network
of things, services or data. Is this correct?
I came across the following thought: When I simulate a billard game with a DES,
I would compute collisions of balls with
each other and with the banks, creatign a set of events, of which only the
earliest will be considered to compute the
next state. This is pure DES and does not seem to be a good candidate for
arrows. In this case I'd be more interested in
composing collision detectors than in stream processing.
OTOH, when I move parcels around and process then in various stages, then a
"stream processor" would make perfect sense
to me. In that case, would I abandon the DES paradigm entirely (including the
notion of an event queue) and just model
the network and let it run?
------------------------------
Message: 5
Date: Tue, 31 Mar 2015 05:39:28 +0000
From: Michael Snoyman <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Is there an aeson-like XML
serialization library?
Message-ID:
<CAKA2JgJzdchrUUboFBpY=+0vyyn-7bws3pn1zc1c8rbkr_w...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
It doesn't have the typeclass stuff built in, but xml-conduit has proper
support for XML namespaces.
On Tue, Mar 31, 2015, 6:27 AM Thomas Koster <[email protected]> wrote:
> Hi list,
>
> I want to write a simple XML web service in Haskell that services a .NET
> WCF client, but am struggling with choosing the right XML library.
>
> "aeson" [1] has been a pleasure to use, so I am looking for an XML
> serialization library similar to aeson, where I can write
> ToElement/FromElement instances using simple applicative combinators,
> working with a high-level document model (i.e. not a parse tree), just like
> I have done in the past with ToJSON/FromJSON.
>
> Does such a library exist?
>
> I need the library to understand XML namespaces and the mandatory
> predefined entities, but I do not need any other extensions like XML
> Schemas, XPath or XSLT. Preferably, "xmlns" attributes should be handled
> specially and namespace prefixes resolved by the parser. "xmlns" attributes
> should be placed automatically by the renderer (I don't care what prefixes
> it chooses). I do not want to have to keep track of seen namespace prefixes
> while I am traversing the document, or to manually place "xmlns" attributes
> on elements for rendering. The "xml" [2] library is giving me grief at the
> moment with how unspecial its treatment of namespaces is.
>
> HXT appears to be beyond my skill level at the moment. There appear to be
> too many new things I would have to learn all at once before I could use it
> for this simple task. Cf. aeson, which I was able to use for practical
> applications the day I learned what an applicative functor was.
>
> [1] https://hackage.haskell.org/package/aeson
> [2] https://hackage.haskell.org/package/xml
>
> Thanks,
> --
> Thomas Koster
>
> _______________________________________________
> 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/20150331/0952887c/attachment-0001.html>
------------------------------
Message: 6
Date: Tue, 31 Mar 2015 09:48:54 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
To: "The Haskell-Beginners Mailing List" <[email protected]>,
"Jeffrey Brown" <[email protected]>
Subject: Re: [Haskell-beginners] Mutable collection of gui objects
(wxHaskell)
Message-ID: <op.xwcqnxsppz0j5l@alquantor>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Tue, 31 Mar 2015 04:14:35 +0200, Jeffrey Brown
<[email protected]> wrote:
:
> I am trying to modify Layout.hs [1] to permit a variable number, rather
> than a fixed number, of text entry boxes. I shrank the program, mostly by
> removing features, until it was this:
>
> main = start $ do
> f <- frame [text := "Layout test"]
> p <- panel f []
> xinput <- textEntry p [text := "100"]
> yinput <- textEntry p [text := "100"]
> myVar <- varCreate [xinput,yinput]
> set f [ layout := container p $ margin 10 $
> column 5 [boxed "coordinates" (grid 5 5
> [[hfill $ widget xinput], [hfill $ widget yinput]] -- replacing
> ) ] ]
> return ()
>
> I want to replace the line marked "replacing". Rather than hard-coding
> the
> number of text entry boxes (2), I want it to deal with a mutable
> collection
> of them, in myVar.
>
> I tried this:
> [ fmap (\e -> hfill $ widget e) $ varGet myVar ]
:
The result of varGet is of type "IO something", you must convert that to
"something", by using "<-". You can do this by adding the line:
inputs <- map (\e -> [hfill $ widget e]) <$> varGet myVar
before the set command (note the square brackets). The <$> operator is
from module Data.Functor and is defined as
(<$>) = fmap
The main function becomes this:
main = start $ do
f <- frame [text := "Layout test"]
p <- panel f []
xinput <- textEntry p [text := "100"]
yinput <- textEntry p [text := "100"]
myVar <- varCreate [xinput, yinput]
inputs <- map (\e -> [hfill $ widget e]) <$> varGet myVar
set f [ layout := container p $ margin 10 $
column 5 [boxed "coordinates" (grid 5 5 inputs)]
]
return ()
Regards,
Henk-Jan van Tuyl
--
Folding@home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 81, Issue 75
*****************************************