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. 'No such file' - ghc Parsec Package Error (Oliver Dean) 2. Re: 'No such file' - ghc Parsec Package Error (Imants Cekusins) 3. Re: 'No such file' - ghc Parsec Package Error (Joseph Melfi) 4. Re: Handling failed output (Mason Lai) ---------------------------------------------------------------------- Message: 1 Date: Mon, 25 Apr 2016 17:06:51 +0000 From: Oliver Dean <o...@st-andrews.ac.uk> To: "The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell" <beginners@haskell.org> Subject: [Haskell-beginners] 'No such file' - ghc Parsec Package Error Message-ID: <e962085b-fda3-406f-bf44-98920610f...@st-andrews.ac.uk> Content-Type: text/plain; charset="utf-8" Hello All, Silly question, I cannot seem to compile an additional .hs file using the ?package parsec ?o command? It has to be something to do with my directory locations no doubt. I?ve tried numerous attempts and still no luck. I have a program called simple_parser which was compiled using the ?parser.hs' file. Now I wish to run and compile with the parsec package using the file ?parsec.hs?? Both my .hs files are located in the same folder: 8afbc4c1:HS_Parser homefolder$ ls parsec.hs parser.hi parser.hs parser.o simple_parser Then when I try the following (and I have tried many different path routes ../../ and vice versa), I get the following: 8afbc4c1:HS_Parser homefolder$ ghc -package parsec -o simple_parser [..parsec.hs parsec.hs] <no location info>: can't find file: [..parsec.hs Sorry to be such a newbie! Any helpful direction would be greatly appreciated. Not sure if I am doing something wrong or my code is?? PS - Both .hs files have slightly differing lines of code (based on the Wiki Book Scheme -> Haskell tutorial). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160425/90a8817a/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 25 Apr 2016 20:45:09 +0200 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] 'No such file' - ghc Parsec Package Error Message-ID: <CAP1qinZnMTfVjLNZWx6Ltjr1B7y+LRNP9ZBo-9q-Wtmwm+=p...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Can cabal be used to compile? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160425/2e2b8d59/attachment-0001.html> ------------------------------ Message: 3 Date: Mon, 25 Apr 2016 12:29:29 -0700 From: "Joseph Melfi" <joseph.d.me...@gmail.com> To: "Imants Cekusins" <ima...@gmail.com>, "The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell" <beginners@haskell.org> Subject: Re: [Haskell-beginners] 'No such file' - ghc Parsec Package Error Message-ID: <571e6fc3921adc0000723...@polymail.io> Content-Type: text/plain; charset="utf-8" cabal build can be used to build the binary in bin. stack can also do the build command to do this as well. Joseph Melfi On Mon, Apr 25, 2016 at 11:45 AM Imants Cekusins < mailto:Imants Cekusins <ima...@gmail.com> > wrote: Can cabal be used to compile? _______________________________________________ Beginners mailing list mailto: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/20160425/9b66e89e/attachment-0001.html> ------------------------------ Message: 4 Date: Mon, 25 Apr 2016 12:47:25 -0700 From: Mason Lai <masonm...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Handling failed output Message-ID: <CAH1iVpdYymoJqZRivqAgfcNNrAR3JFOHZOiJ=wei3afakt0...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I know you're asking for a function that will either return an Int or a (Int, Int). However, in my limited experience, I haven't seen Ints used as error codes in Haskell. Typically, I see something like the following: checkNum3 :: Int -> Int -> Either String (Int,Int) checkNum3 a b = if check a b then Right (a, b) else Left "Error: something happened" Then you can use a function like (either error id) to either extract the (Int, Int) value or to raise the error with the message. The (either error id) function will look at an Either value. If it's a Left value, it will call error on that value -- so (error "Error: something happened"). If it's a Right value, it will call id on that value -- so id (a, b) which evaluates to (a, b). I usually use this setup if I lazily parse a huge file of text data, where each line has some constraint that makes the file "valid" or "invalid". I end up with a long list of Either String (Int, Int)s, and I then map (either error id) over the list. On Sat, Apr 23, 2016 at 2:05 PM, Imants Cekusins <ima...@gmail.com> wrote: > Hello Matt, > > Either Int (Int,Int) might work. > > Left ... by convention indicates 'other' result. > > _______________________________________________ > 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/20160425/9d359c90/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 94, Issue 26 *****************************************