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. compilation error for jhc (Fabien R) 2. Re: compilation error for jhc (David McBride) 3. Parsing 'A's and then ('A's or 'B's) (Simon Jakobi) 4. Re: Parsing 'A's and then ('A's or 'B's) (Francesco Ariis) 5. Re: Parsing 'A's and then ('A's or 'B's) (Simon Jakobi) 6. Re: Functional Programming for the Object Oriented (?ystein Kolsrud) 7. Re: Parsing 'A's and then ('A's or 'B's) (Alex Belanger) ---------------------------------------------------------------------- Message: 1 Date: Sun, 24 Jan 2016 13:05:16 +0100 From: Fabien R <theedge...@free.fr> To: Haskell Beginners <beginners@haskell.org> Subject: [Haskell-beginners] compilation error for jhc Message-ID: <56a4bdfc.8070...@free.fr> Content-Type: text/plain; charset=utf-8; format=flowed Hello, I want to build jhc 0.82 on debian/amd64. I downloaded the sources and successfully configured the build. The compilation fails with this error: [149 of 186] Compiling Ho.Binary ( src/Ho/Binary.hs, src/Ho/Binary.o ) src/Ho/Binary.hs:164:10: Duplicate instance declarations: instance [overlap ok] Binary Data.Version.Version -- Defined at src/Ho/Binary.hs:164:10 instance [safe] Binary Data.Version.Version -- Defined in `binary-0.8.0.0:Data.Binary.Class' Makefile:1441: recipe for target 'jhc' failed The corresponding source code in src/Ho/Binary.hs is: import Data.Binary import qualified Data.Version instance Binary Data.Version.Version where put (Data.Version.Version a b) = put a >> put b get = liftM2 Data.Version.Version get get In the package binary, is this error due to this line ? import Data.Version (Version(..)) Any hint to solve this ? -- Fabien ------------------------------ Message: 2 Date: Sun, 24 Jan 2016 08:59:03 -0500 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] compilation error for jhc Message-ID: <CAN+Tr40P=edvxzo6mbfiwzxe1fjk8x3s2qtu5_rvxbfxvcw...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" It looks like the binary package got its own instance for the version datatype. You could probably make it build by just removing that instance from Binary.hs. And I don't want to dissuade you, but unless there is a reason for you to use jhc, just be aware that ghc has pretty much become the defacto haskell compiler and the others have started to bit rot. On Sun, Jan 24, 2016 at 7:05 AM, Fabien R <theedge...@free.fr> wrote: > Hello, > I want to build jhc 0.82 on debian/amd64. > I downloaded the sources and successfully configured the build. > The compilation fails with this error: > > [149 of 186] Compiling Ho.Binary ( src/Ho/Binary.hs, > src/Ho/Binary.o ) > > src/Ho/Binary.hs:164:10: > Duplicate instance declarations: > instance [overlap ok] Binary Data.Version.Version > -- Defined at src/Ho/Binary.hs:164:10 > instance [safe] Binary Data.Version.Version > -- Defined in `binary-0.8.0.0:Data.Binary.Class' > Makefile:1441: recipe for target 'jhc' failed > > The corresponding source code in src/Ho/Binary.hs is: > > import Data.Binary > import qualified Data.Version > > instance Binary Data.Version.Version where > put (Data.Version.Version a b) = put a >> put b > get = liftM2 Data.Version.Version get get > > In the package binary, is this error due to this line ? > > import Data.Version (Version(..)) > > Any hint to solve this ? > > -- > Fabien > > _______________________________________________ > 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/20160124/4ed16a7e/attachment-0001.html> ------------------------------ Message: 3 Date: Sun, 24 Jan 2016 19:11:08 +0100 From: Simon Jakobi <simon.jak...@googlemail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Parsing 'A's and then ('A's or 'B's) Message-ID: <CAGtp2ShFLsmdAsbHRA1gVfx_vGu6TvWyOyef=1PjYtVTn=0...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi! I want to test whether a sequence of the characters 'A' and 'B' can represent a sequence of the symbols x and y where x may be represented by one or more 'A's and y may be represented by one or more 'A's or one or more 'B's. In code, I would like to see the following: ?> "AABB" `represents` [x, y] True ?> "AA" `represents` [x, y] True But with my current implementation using attoparsec only the first example works as expected: import Control.Applicative import Data.Attoparsec.ByteString.Char8 import Data.ByteString import Data.Either import Data.Foldable import Data.Word type Symbol = Parser [Word8] x :: Symbol x = many1 (char8 'A') y :: Symbol y = many1 (char8 'A') <|> many1 (char8 'B') represents :: ByteString -> [Symbol] -> Bool bs `represents` symbols = isRight $ parseOnly ((sequenceA_ symbols) *> endOfInput) bs It seems that in "AA" `represents` [x, y] x consumes all the 'A's, leaving none for y. Is it possible to solve this with attoparsec or are there other parsing libraries that I could use instead? Cheers, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160124/7307068c/attachment-0001.html> ------------------------------ Message: 4 Date: Sun, 24 Jan 2016 20:19:42 +0100 From: Francesco Ariis <fa...@ariis.it> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Parsing 'A's and then ('A's or 'B's) Message-ID: <20160124191942.ga1...@casa.casa> Content-Type: text/plain; charset=utf-8 On Sun, Jan 24, 2016 at 07:11:08PM +0100, Simon Jakobi wrote: > I want to test whether a sequence of the characters 'A' and 'B' can > represent a sequence of the symbols x and y where x may be represented by > one or more 'A's and y may be represented by one or more 'A's or one or > more 'B's. > > In code, I would like to see the following: > > ?> "AABB" `represents` [x, y] > True > ?> "AA" `represents` [x, y] > True Hello Simon, if I understood your specification correctly, there would be multiple ways to parse the string "AAA": - 3 'x' elements ("A", "A", "A") - 2 'x' elements ("AA", "A") - 2 'x' elements again (first one shorter) ("A", "AA") - 1 'x' element ("AAA") Which of these four should we choose? Maybe "parse as many As as possible without consuming the A followed by a series of B"? If so, a useful combinator is `notFollowedBy` (present in parsec, pretty sure is in attoparsec too, if not it can be easily replicated). Does that help? ------------------------------ Message: 5 Date: Sun, 24 Jan 2016 22:56:31 +0100 From: Simon Jakobi <simon.jak...@googlemail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Parsing 'A's and then ('A's or 'B's) Message-ID: <cagtp2shvdbslft-wwk+6tpzrha-g50bvbkfhavvfdau-zcy...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Francesco, Thanks for your response! > if I understood your specification correctly, there would be multiple > ways to parse the string "AAA": > > - 3 'x' elements ("A", "A", "A") > - 2 'x' elements ("AA", "A") > - 2 'x' elements again (first one shorter) ("A", "AA") > - 1 'x' element ("AAA") > There would be even more ways because 'y', too, can represent one or more 'A's. Which of these four should we choose?Maybe "parse as many As as possible > without consuming the A followed by a series of B"? I don't think that there could be a general rule. For the string "AABB" and the sequence of symbols [x, y, y] there would be two possible parses: [x: "AA", y: "B", y: "B"] or [x: "A", y: "A", y: "BB"]. I only care whether there are any valid parses. I've just tried to solve the problem with regular expressions (using pcre-light) and didn't come across the same problem. Is this due to attoparsec not being able to "backtrack" (not sure if this is the right term)? Is backtracking something that parsers generally are incapable of? Cheers, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160124/d7ff15db/attachment-0001.html> ------------------------------ Message: 6 Date: Sun, 24 Jan 2016 23:35:01 +0100 From: ?ystein Kolsrud <kols...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Functional Programming for the Object Oriented Message-ID: <CAH_oh=wq34gNn+hZ-fid3z-iDoewQLW2rC09gEDaGHGB27=u...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Great! I hope it was useful to you. Best regards, ?ystein Kolsrud On Tue, Dec 8, 2015 at 12:45 PM, David Moberg <kaddk...@gmail.com> wrote: > Thanks I liked this video! :) > > 2015-11-18 20:35 GMT+01:00 ?ystein Kolsrud <kols...@gmail.com>: >> >> I gave a presentation on functional programming a couple of weeks ago >> that I thought might be of interest to this community as well: >> >> https://www.youtube.com/watch?v=I2tMmsZC1ZU >> >> It's target audience is programmers familiar with object oriented >> programming, and it presents how concepts from the functional paradigm >> are relevant also in most modern OO languages. >> >> For more information about the presentation, please refer to the following >> site: >> >> >> http://www.foocafe.org/previous_event/functional-programming-for-the-object-oriented >> ------------------------------ Message: 7 Date: Mon, 25 Jan 2016 01:10:09 -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] Parsing 'A's and then ('A's or 'B's) Message-ID: <cadsky2xwlkhar7k5jpgfc5ybo+r-qph7xxvij_jurmatzfy...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" If I understood properly, Have you considered breaking the input into some sort of pattern mask then validating it? map (length . group) "AAABB" === [3,2]. Then you can do the same thing grouping with the target [x, x, y] into [2, 1]. Then you can zip the lists and ensure the numbers are all smaller than the other respectively. Also, the lists themselves have the right lengths and order for their elements. Examples of successful patterns: [1,1] AAA,BB [1, 2] AAA,B,B [2,1] A,AA,BB AA,A,BB [2,2] A,AA,B,B AA,A,B,B Try with other examples I think this would work. On Jan 24, 2016 4:57 PM, "Simon Jakobi" <simon.jak...@googlemail.com> wrote: > Hi Francesco, > > Thanks for your response! > > >> if I understood your specification correctly, there would be multiple >> ways to parse the string "AAA": >> >> - 3 'x' elements ("A", "A", "A") >> - 2 'x' elements ("AA", "A") >> - 2 'x' elements again (first one shorter) ("A", "AA") >> - 1 'x' element ("AAA") >> > > There would be even more ways because 'y', too, can represent one or more > 'A's. > > Which of these four should we choose?Maybe "parse as many As as possible >> without consuming the A followed by a series of B"? > > > I don't think that there could be a general rule. > > For the string "AABB" and the sequence of symbols [x, y, y] there would be > two possible parses: > > [x: "AA", y: "B", y: "B"] > or > [x: "A", y: "A", y: "BB"]. > > I only care whether there are any valid parses. > > I've just tried to solve the problem with regular expressions (using > pcre-light) and didn't come across the same problem. Is this due to > attoparsec not being able to "backtrack" (not sure if this is the right > term)? Is backtracking something that parsers generally are incapable of? > > Cheers, > Simon > > _______________________________________________ > 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/20160125/11fd5ab8/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 29 *****************************************