Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/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. Re: Understandig types (Michael Xavier) 2. error handling in libraries (Michael Xavier) 3. Re: How to process a list that contains "undefined" values? (Mike Meyer) 4. Re: How to process a list that contains "undefined" values? (Daniel Fischer) 5. First haskell package.. (Mike Meyer) 6. Re: First haskell package.. (Mike Meyer) ---------------------------------------------------------------------- Message: 1 Date: Sat, 2 Jul 2011 12:00:44 -0700 From: Michael Xavier <nemesisdes...@gmail.com> Subject: Re: [Haskell-beginners] Understandig types To: moow...@fastmail.fm Cc: beginners@haskell.org Message-ID: <CANk=zmfm2uqjcvwrpp5pp6_tixlv62kenbxo3zn720lfk6q...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I do agree you should look at the tutorial but to answer your questions, see below: 1) what's the difference between these two code statements? I'm > convinced they should be the same > > type T = [Char] > type CurrentValue = Char > > You could think of the type keyword as aliasing an existing type to one that you name. For instance, T can now be used interchangeably with the [Char] type, like in a type declaration: upcase :: [Char] -> [Char] can be: upcase :: T -> T and they would mean the same thing. You do this usually for the sake of documentation, where the alias you are creating is more readable than that which it aliases. [Char] means an array of Chars. String, for example is I believe defined as: type String = [Char] > 2) What is Maybe String? > > Maybe String is a datatype that could be 1 of 2 things, a String or Nothing. Maybe is used a lot of the time for computations that may fail, such as looking for a needle in a haystack: findNeedle :: NeedleID -> Haystack -> Maybe Needle In that example, findNeedle would return the value: Just someneedle OR it would return Nothing if it could not be found. I encourage you to read up on the tutorial that David Place submitted for more information. > For instance: type P = (Char, Maybe String) > P in this case is a tuple or pair. That's what the parentheses are for. It means that the first field of the tuple is a Char, the second field of of the tuple can either be a string or nothing. Again, this is a type, not a value or a function. > 3) What is Maybe Char ? > > See above. -- Michael Xavier http://www.michaelxavier.net -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110702/ed6cffa2/attachment-0001.htm> ------------------------------ Message: 2 Date: Sat, 2 Jul 2011 19:29:10 -0700 From: Michael Xavier <nemesisdes...@gmail.com> Subject: [Haskell-beginners] error handling in libraries To: Haskell Beginners <beginners@haskell.org> Message-ID: <CANk=zmgm77nghkjn4nk+47r4x6pet6lwcsxjq6_a577krny...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi Beginners, A little while ago I wrote my first library. Internally, it is pretty solid but it makes API calls out to the internet so network problems can be an issue. Additionally, if the API that I'm calling decides to change their format in the future, it is probably not a good idea that my library crash the program that uses it. I'm curious what the current best practice is for handling exceptions in library code. I realize that in self-contained projects, it is much easier to choose whatever you want because it will not directly effect the user, but in a library one must consider what exception handling system the end user is most likely to know. -- Michael Xavier http://www.michaelxavier.net -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110702/2c668eda/attachment-0001.htm> ------------------------------ Message: 3 Date: Sun, 3 Jul 2011 02:40:03 -0400 From: Mike Meyer <m...@mired.org> Subject: Re: [Haskell-beginners] How to process a list that contains "undefined" values? To: beginners@haskell.org Message-ID: <20110703024003.67082...@bhuda.mired.org> Content-Type: text/plain; charset=US-ASCII On Sat, 2 Jul 2011 16:32:37 +0200 Daniel Fischer <daniel.is.fisc...@googlemail.com> wrote: > On Saturday 02 July 2011, 16:09:05, Costello, Roger L. wrote: > > Hi Folks, > > > > How would you find the maximum value in this list: > > > > [undefined, 10, undefined, 20] > Not. There is no proper maximum in the presence of undefined. Doesn't that mean the maximum value for this list is also "undefined"? That matches my intuition, which is that undefined should be a "contagious" value, so that any value that depends on evaluating an undefined value is itself undefined. <mike -- Mike Meyer <m...@mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org ------------------------------ Message: 4 Date: Sun, 3 Jul 2011 10:47:40 +0200 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] How to process a list that contains "undefined" values? To: beginners@haskell.org Message-ID: <201107031047.40916.daniel.is.fisc...@googlemail.com> Content-Type: Text/Plain; charset="iso-8859-1" On Sunday 03 July 2011, 08:40:03, Mike Meyer wrote: > On Sat, 2 Jul 2011 16:32:37 +0200 > > Daniel Fischer <daniel.is.fisc...@googlemail.com> wrote: > > On Saturday 02 July 2011, 16:09:05, Costello, Roger L. wrote: > > > Hi Folks, > > > > > > How would you find the maximum value in this list: > > > [undefined, 10, undefined, 20] > > > > Not. There is no proper maximum in the presence of undefined. > > Doesn't that mean the maximum value for this list is also "undefined"? Yes, and that way, a simple call to maximum does the right thing (note however, that it doesn't necessarily does the right thing for lists of Double/Float containing NaNs). I assumed the OP wanted the maximum of the defined values, in which case such a situation is best avoided by using Maybe or something serving similar purposes. > That matches my intuition, which is that undefined should be a > "contagious" value, so that any value that depends on evaluating an > undefined value is itself undefined. Right. Except that in IO exceptions can be caught which muddies the waters (is foo = bar `Control.Exception.catch` (\(ErrorCall msg) -> if msg == "Prelude.undefined" then return 1 else return 2) legit?) ------------------------------ Message: 5 Date: Sun, 3 Jul 2011 05:08:27 -0400 From: Mike Meyer <m...@mired.org> Subject: [Haskell-beginners] First haskell package.. To: beginners@haskell.org Message-ID: <20110703050827.4b844...@bhuda.mired.org> Content-Type: text/plain; charset=US-ASCII After much dithering, I'm finally ready to release a first haskell project, eddie. I figured I'd run it past the helpful people here for feedback before making a more official announcement. eddie is a command line tool that lets you use haskell functions to filter files. Functions is meant in the most general sense - any expression that can be evaluated to a type of "String -> String" can be used. The home page is http://eddie.googlecode.com/. There are a couple of pages of examples in the wiki. The 0.1 source tarball is available in downloads, and includes the .cabal file for building. It's not in hackage yet - I'm awaiting a username. <mike -- Mike Meyer <m...@mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org ------------------------------ Message: 6 Date: Sun, 3 Jul 2011 05:16:49 -0400 From: Mike Meyer <m...@mired.org> Subject: Re: [Haskell-beginners] First haskell package.. To: beginners@haskell.org Message-ID: <20110703051649.7c2f8...@bhuda.mired.org> Content-Type: text/plain; charset=US-ASCII On Sun, 3 Jul 2011 05:08:27 -0400 Mike Meyer <m...@mired.org> wrote: > It's not in hackage yet - I'm awaiting a username. Well, it's been uploaded. Not sure how long before it starts showing up in searches. <mike -- Mike Meyer <m...@mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 37, Issue 5 ****************************************