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: Implementing instance of '^' operator (Chadda? Fouch?) 2. Re: Ambiguous module name `Prelude': it was found in multiple packages (trying to install HXQ) (Chadda? Fouch?) 3. proving fmap law for recursive data types (???) 4. Re: proving fmap law for recursive data types (Kim-Ee Yeoh) ---------------------------------------------------------------------- Message: 1 Date: Sat, 16 Jan 2016 21:05:06 +0000 From: Chadda? Fouch? <chaddai.fou...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Implementing instance of '^' operator Message-ID: <canfjzraowmcyh8kr30txuq3mttf0bsureuax_hnwnxqspfp...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" (^) is _not_ a method of Num, it is simply a function with a Num constraint. It will work on your new numbers as well as it would on any other that implements (*) correctly, you don't need to rewrite it. By the way, your functions are dangerously partial, it would seem useful to put the prime into the type so that you can't add or multiply different Mod p. Of course this demands a bit more knowledge of Haskell type system than is likely in a beginner, but if you're motivated, I encourage you to look at numbers in type (see GHC.TypeLits maybe). -- Jeda? Le dim. 3 janv. 2016 ? 14:07, Harald Hanche-Olsen <han...@math.ntnu.no> a ?crit : > -----Original Message----- > From: pmcil...@gmail.com <pmcil...@gmail.com> > Date: 3 January 2016 at 07:55:53 > > > As a ?hello world? example for type definitions, I like to define a > numeric type that can > > handle the mod p multiplicative group, where p is prime. This requires: > > ? Implementing interface functions > > [?] > > I can?t help with the question you?re asking, but I have a minor nitpick: > You want to have > negate (Modp p 0) = Modp p 0, > and not Modp p p as in your current implementation. > > ? Harald > _______________________________________________ > 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/20160116/b6c14373/attachment-0001.html> ------------------------------ Message: 2 Date: Sat, 16 Jan 2016 21:14:47 +0000 From: Chadda? Fouch? <chaddai.fou...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Ambiguous module name `Prelude': it was found in multiple packages (trying to install HXQ) Message-ID: <CANfjZRZknV4TV5yxy=frfjbrehbny1ac7zrv6iyfi_zmzea...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Le mar. 5 janv. 2016 ? 22:16, Henk-Jan van Tuyl <hjgt...@chello.nl> a ?crit : > You can do "cabal unpack hxq" and update the file hxq.cabal; I tried it > and there are many more things that need updates. Your best bet would be > to ask the author to update the package. Otherwise, you could ask the > Haskell Caf? if someone would like to take over maintenance of HXQ. Apparently someone did update HXQ : Leonidas Fegaras, the original maintainer, updated HXQ on the 7 january 2016. I can only assume that Stanislaw contacted him directly. Just to conclude the discussion on a positive note ! -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160116/c87d435f/attachment-0001.html> ------------------------------ Message: 3 Date: Sat, 16 Jan 2016 19:17:59 -0800 From: ??? <traqueofzi...@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] proving fmap law for recursive data types Message-ID: <CAMjcG+HazdkDXyjKwMURRiJmCBSjW=f+e06xmujvsvhs81z...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, Suppose you have something like: data Tree a = Leaf a | Branch (Tree a) (Tree a) instance Functor Tree where fmap f (Leaf a) = Leaf $ f a fmap f (Branch l r) = Branch (fmap f l) (fmap f r) To check that fmap id = id, I can see that the case for Leaf is ok: fmap id (Leaf a) = Leaf $ id a = Leaf a How would you prove it for the second case? Is some sort of inductive proof necessary? I found this: http://ssomayyajula.github.io/posts/2015-11-07-proofs-of-functor-laws-with-Haskell.html, which goes over an inductive (on the length of the list) proof for the list type, but I'm not sure how to do it for a Tree. Thanks, toz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160116/5310632a/attachment-0001.html> ------------------------------ Message: 4 Date: Sun, 17 Jan 2016 11:47:33 +0700 From: Kim-Ee Yeoh <k...@atamo.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] proving fmap law for recursive data types Message-ID: <capy+zdrbwxhygen8phu6z35osecqqsqhxx5lbvzvep+c--0...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" On Sun, Jan 17, 2016 at 10:17 AM, ??? <traqueofzi...@gmail.com> wrote: How would you prove it for the second case? Is some sort of inductive proof > necessary? I found this: > http://ssomayyajula.github.io/posts/2015-11-07-proofs-of-functor-laws-with-Haskell.html, > which goes over an inductive (on the length of the list) proof for the list > type, but I'm not sure how to do it for a Tree. > You've got the right idea. The general outline of a simple inductive proof is this: 1. Prove for the smallest case (in this case, a tree with just one Leaf) 2. While assuming that the hypothesis holds for a small case, prove hypothesis for the next case one up in size 3. Put 1 and 2 together to claim hypothesis for all cases You've done 1. You're stuck at 2 because you haven't yet found some measure of a "size" of a Tree. What are some common Tree measures you've seen? -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160117/776e85e0/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 91, Issue 23 *****************************************