Send Beginners mailing list submissions to beginners@haskell.org 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 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. wxHaskell: add an external event from another thread (Puck) 2. Pattern Matching for record syntax (Jeon-Young Kang) 3. Re: Pattern Matching for record syntax (Magnus Therning) 4. Re: Pattern Matching for record syntax (Imants Cekusins) 5. Re: Pattern Matching for record syntax (Jeon-Young Kang) 6. Re: Pattern Matching for record syntax (Imants Cekusins) 7. Re: Pattern Matching for record syntax (Imants Cekusins) ---------------------------------------------------------------------- Message: 1 Date: Thu, 7 Jan 2016 22:27:44 +0100 From: Puck <lis...@freea2a.de> To: "beginners@haskell.org" <beginners@haskell.org> Subject: [Haskell-beginners] wxHaskell: add an external event from another thread Message-ID: <20160107222744.283494eb@noordzee> Content-Type: text/plain; charset=US-ASCII Hello all, how is it possible to process external events, for example a succeeded getLine or a takeMVar with its values in the wxHaskell framework? The reason is, that I want to connect a erlang node to wxHaskell. I have found the functions Graphics.UI.WX.Events.newEvent :: String -> (w -> IO a) -> (w -> a -> IO ()) -> Event w a "Create a new event from a get and set function." Beside from, that I don't know what the get and set function shall do, I don't know, how I can add the new event to the event-loop of wx, and when it "fires". Do you know any possibilities? Thank you in advance ------------------------------ Message: 2 Date: Thu, 7 Jan 2016 16:54:47 -0500 From: Jeon-Young Kang <jykan...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org>, haskell-c...@haskell.org Subject: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <CALWtiK8_+Hh_ZVM-J_RgKHRY=cykfhy4cb9zph+c7bqfu9f...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Dear All. Hope your 2016 is off to a great start. I would like to get results from pattern matching or something. Here is the my code. data Person = Person {name :: String, age :: Int} names = ["tom", "sara"] -- list of names, String persons = [Person {name = "tom", age = 10}, Person {name="sara", age=9}, Person {name = "susan", age = 8}]. Is there any solution to get the age of "tom" and "sara"? I have no idea of pattern matching for this one. I've tried to use recursion, but I couldn't find any solution for list of records. Sincerely, Young -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/4657fc47/attachment-0001.html> ------------------------------ Message: 3 Date: Thu, 07 Jan 2016 23:24:18 +0100 From: Magnus Therning <mag...@therning.org> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Cc: haskell-c...@haskell.org Subject: Re: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <871t9tkoz1....@therning.org> Content-Type: text/plain; charset="utf-8" Jeon-Young Kang writes: > Dear All. > > Hope your 2016 is off to a great start. > > I would like to get results from pattern matching or something. > > Here is the my code. > > data Person = Person {name :: String, age :: Int} > > names = ["tom", "sara"] -- list of names, String > > persons = [Person {name = "tom", age = 10}, Person {name="sara", age=9}, > Person {name = "susan", age = 8}]. > > Is there any solution to get the age of "tom" and "sara"? > > I have no idea of pattern matching for this one. > > I've tried to use recursion, but I couldn't find any solution for list of > records. How about using `filter`[1] over `persons` with a function checking if the name is in `names`? I'm sorry, but this sounds like home work so you won't get more than this from me. /M [1]: http://hackage.haskell.org/package/base-4.8.1.0/docs/Data-List.html#v:filter -- Magnus Therning OpenPGP: 0x927912051716CE39 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus Would you go to war without a helmet? Would you drive without the seat belt? Then why do you develop software as if shit doesn?t happen? -- Alberto G ( http://makinggoodsoftware.com/2009/05/12/hdd/ ) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 800 bytes Desc: not available URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/95d28a71/attachment-0001.sig> ------------------------------ Message: 4 Date: Thu, 7 Jan 2016 23:28:54 +0100 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <CAP1qinbze4Gf+L_uPz0O-J=nmufhm-xv8mkqzm1s-msq97q...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" you could filter record list http://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#v:filter \r -> elem (name r) names then fmap the filtered list to extract age age <$> list1 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/0de2bd5b/attachment-0001.html> ------------------------------ Message: 5 Date: Thu, 7 Jan 2016 17:29:10 -0500 From: Jeon-Young Kang <jykan...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <calwtik-vrfcbmzqc553fc-yt+p3p2_fdo5th1i291_4jkwk...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Thanks Magnus Therning. Actually, this is NOT homework. I am just studying Haskell for my current research. I've tried "filter" before. But I couldn't reach what I want to do. it seems that filter is only applicable to list, not "record syntax". Do I need functor for this?? Best, On Thu, Jan 7, 2016 at 5:24 PM, Magnus Therning <mag...@therning.org> wrote: > > Jeon-Young Kang writes: > > > Dear All. > > > > Hope your 2016 is off to a great start. > > > > I would like to get results from pattern matching or something. > > > > Here is the my code. > > > > data Person = Person {name :: String, age :: Int} > > > > names = ["tom", "sara"] -- list of names, String > > > > persons = [Person {name = "tom", age = 10}, Person {name="sara", age=9}, > > Person {name = "susan", age = 8}]. > > > > Is there any solution to get the age of "tom" and "sara"? > > > > I have no idea of pattern matching for this one. > > > > I've tried to use recursion, but I couldn't find any solution for list of > > records. > > How about using `filter`[1] over `persons` with a function checking if > the name is in `names`? > > I'm sorry, but this sounds like home work so you won't get more than > this from me. > > /M > > [1]: > http://hackage.haskell.org/package/base-4.8.1.0/docs/Data-List.html#v:filter > > -- > Magnus Therning OpenPGP: 0x927912051716CE39 > email: mag...@therning.org jabber: mag...@therning.org > twitter: magthe http://therning.org/magnus > > Would you go to war without a helmet? Would you drive without the seat > belt? Then why do you develop software as if shit doesn?t happen? > -- Alberto G ( http://makinggoodsoftware.com/2009/05/12/hdd/ ) > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/aa759362/attachment-0001.html> ------------------------------ Message: 6 Date: Thu, 7 Jan 2016 23:33:55 +0100 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <CAP1qinbqTYMUoSHXb0cEhvceGu=ssrwkqdhvqddeb8hj-bg...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" if you must use pattern matching, here is a tip: (Person name0 age0) i.e. records are like tuples with values in the order of declared record fields. name0 can be named anything else. To match any field value, use _ for that field -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/07ee45f4/attachment-0001.html> ------------------------------ Message: 7 Date: Thu, 7 Jan 2016 23:37:44 +0100 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Pattern Matching for record syntax Message-ID: <CAP1qinbAHU5NUTcf8Z9AsGEb16d+CKQUD2fUJrp9yfM-NM=a...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" > filter is only applicable to list, not "record syntax". but [Person] is the input, isn't it? > Do I need functor for this?? no need to define new functor instance to filter over a list of records. but you could use fmap over list, yes -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160107/64d2d0fe/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 91, Issue 11 *****************************************