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. Application of lookup function (Jeon-Young Kang) 2. Re: Application of lookup function (Alex Belanger) 3. Re: More type errors I'm having trouble with (Daniel Trstenjak) 4. Re: More type errors I'm having trouble with (Daniel Trstenjak) ---------------------------------------------------------------------- Message: 1 Date: Thu, 3 Dec 2015 23:46:25 -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: [Haskell-beginners] Application of lookup function Message-ID: <CALWtiK_pZedoNm0==DrgTMwwMCSc=_NeccH4Nx=mh18zq7b...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi all. I'd like to apply lookup function (Data.Map) for what I am working on. Here is my code. data Person = Person {personId :: Int, name = String} data People = [Person] data State = InMembership | NoMemebership person1 = Person {1 = personId, "James" = name} person2 = Person {2 = personId, "Tom" = name} members = People [person1, person2] class Belonging a where belonging :: a -> [a] -> Bool -> State here is the problem... I don't know how to get to know whether a person is belong to members. I'd like to find it through a person's name. Can you suggest any examples?? Sincerely, Jeon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151203/873b7895/attachment-0001.html> ------------------------------ Message: 2 Date: Thu, 3 Dec 2015 23:50:51 -0500 From: Alex Belanger <i.caught....@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Application of lookup function Message-ID: <CADSky2xaMUavFTBnqXTvZ959yeEgNH=dai3zumagpoefhco...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" The (`elem` members) function will tell you if the person is a member of members. You can then turn that boolean into your custom State type. On Dec 3, 2015 11:46 PM, "Jeon-Young Kang" <jykan...@gmail.com> wrote: > Hi all. > > I'd like to apply lookup function (Data.Map) for what I am working on. > > Here is my code. > > data Person = Person {personId :: Int, name = String} > data People = [Person] > > data State = InMembership | NoMemebership > > person1 = Person {1 = personId, "James" = name} > person2 = Person {2 = personId, "Tom" = name} > > members = People [person1, person2] > > class Belonging a where > belonging :: a -> [a] -> Bool -> State > > here is the problem... > I don't know how to get to know whether a person is belong to members. > I'd like to find it through a person's name. > > Can you suggest any examples?? > > Sincerely, > Jeon > > > > _______________________________________________ > 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/20151203/04619a80/attachment-0001.html> ------------------------------ Message: 3 Date: Fri, 4 Dec 2015 09:35:18 +0100 From: Daniel Trstenjak <daniel.trsten...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] More type errors I'm having trouble with Message-ID: <20151204083518.GA1841@octa> Content-Type: text/plain; charset=us-ascii Hi Dan, > io_hash_tuples <- map do_prefix_hash filenames You're operating inside of the IO monad, so anything on the right hand side of the `<-` has to have the type `IO`. If you're looking up the type of `map`, you will see that it doesn't return the right type. Most likely you just wanted to create a binding like: let io_hash_tuples = map do_prefix_hash filenames > hash_tuples <- sequence io_hash_tuples `io_hash_tuples` is of type `[(IO String, String)]`, but `sequence` expects a `[IO a]`. Looking at your code, it's easier not to put the `IO String` computation of the hash into a tuple, but first compute all hashes: hashes <- sequence (map Md5s.prefix_md5 filenames) And if you want the hash and the filename grouped in a tuple: zip filenames hashes Greetings, Daniel ------------------------------ Message: 4 Date: Fri, 4 Dec 2015 10:16:16 +0100 From: Daniel Trstenjak <daniel.trsten...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] More type errors I'm having trouble with Message-ID: <20151204091616.GA4649@octa> Content-Type: text/plain; charset=us-ascii > hashes <- sequence (map Md5s.prefix_md5 filenames) That could be just written as: hashes <- mapM Md5s.prefix_md5 filenames Greetings, Daniel ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 90, Issue 7 ****************************************