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. Re: safe versions of pred and succ? (Graham Gill) 2. Re: Feedback needed - CLI app + guide (Carlo Matteo Scalzo) ---------------------------------------------------------------------- Message: 1 Date: Mon, 16 Jan 2017 10:59:38 -0500 From: Graham Gill <math.simp...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] safe versions of pred and succ? Message-ID: <c956cc1c-3b79-23fe-07e1-d4e8d98b8...@gmail.com> Content-Type: text/plain; charset="utf-8"; Format="flowed" Thanks very much for that clear reply Michael. I don't have an application in mind specifically, the example function groupConsecutive just came up in another message and set me wondering: if I have a function to work on types of class A, but types that are instances of both class A and class B are problematic, is there a way to distinguish the cases? As you say, it's probably not class A that I want my function to work over, but instead my own type class. Graham On 15 Jan 2017 14:09, "Michael Orlitzky" <mich...@orlitzky.com <mailto:mich...@orlitzky.com>> wrote: On 01/14/2017 02:35 AM, Graham Gill wrote: > > Do I need two different versions of f, one for Bounded a and one for > non-Bounded a? Is there a more elegant way to take care of this problem? > I don't know much about all of the type magic available in GHC. > You probably want your own typeclass instead of Enum, even if it means generating a bunch of very boring instances of it for the types you want "f" to work on. The fact that "pred" should throw a runtime error on "minBound" is a documented fact of the Enum typeclass, and you should stay far far away from such things in your own code. Besides that, there's a weird interaction between the semantic meaning of Enum and Bounded. For example, here's a perfectly valid enumeration of boolean values: True, False, True, False, ... In your case it would be fine to have (pred False) == True, but instead you get a runtime error thanks to the Bounded instance. So being Bounded rules out some otherwise valid (and fine for your purposes) Enum instances. Your "f" should also work on a singleton type: ghci> data Foo = Foo deriving (Eq,Show) ghci> instance Enum Foo where toEnum _ = Foo; fromEnum _ = 0; ghci> groupConsecutive [Foo,Foo,Foo,Foo] [[Foo,Foo,Foo,Foo]] But any Bounded instance for Foo would mess that up. Basically, the pre-existing Enum instances aren't exactly what you want. _______________________________________________ Beginners mailing list Beginners@haskell.org <mailto:Beginners@haskell.org> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners <http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170116/e3ffa1c9/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 16 Jan 2017 18:00:23 +0000 From: Carlo Matteo Scalzo <cmsca...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Feedback needed - CLI app + guide Message-ID: <CAMYQryed12zMf9o74hy4FP_zCQQ==avvowbequ-ocpppeq7...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Magnus, thank you very much for your feedback! I'm trying to keep things simple for now, but I'll think about your suggestions (and thank you for pointing those out). Did you have the chance to look at guide? I'd love to get your feedback on the content, if you have time. Thanks again! Carlo On 16 Jan 2017 06:32, "Magnus Therning" <mag...@therning.org> wrote: Carlo Matteo Scalzo <cmsca...@gmail.com> writes: > Hi all, > > I'm new to the community here, so please do let me know if I'm doing > something wrong :-) > > I've been learning Haskell over the last year or so, reading books etc., > but I couldn't find a simple, real world example, so I decided to to write > a simple command-line application in Haskell. > > The application and the code are free, and I've also written a short guide > that uses the application as a use case to talk about Haskell and its > features. > > Can you guys please download the guide (for free, of course) , and let me > know if you found it useful? > > You can find it here: > > https://fifohaskell.com > > Please let me have your feedback (my personal email is on the website, if > you don't want to reply here) - and thank you very much for your help! Just had a quick look and things that I notice are: 1. Keep your source in a VCS like gitlab/github/etc? 2. It would be nice of you to put a copyright notice in the source so users know what they may do with the source. 3. Please do create a proper package for it so you can publish it to Hackage. /M -- Magnus Therning OpenPGP: 0x927912051716CE39 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus As someone who's worked at multiple proprietary software companies, having a roadmap doesn't magically make code happen. — Josh Berkus (found in LWN 2016-04-16) _______________________________________________ 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/20170116/393a5668/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 103, Issue 13 ******************************************