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. binding vs. parameter passing (James Jones) 2. Re: binding vs. parameter passing (Ramnath R Iyer) 3. Stack doesn't find downloaded module (Miguel Angel Ordoñez Silis) 4. Re: Stack doesn't find downloaded module (Norbert Melzer) ---------------------------------------------------------------------- Message: 1 Date: Mon, 22 Jul 2019 21:29:30 -0500 From: James Jones <jejones3...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] binding vs. parameter passing Message-ID: <CAFY=adagm7io4t1umsmz35vjbzk0snxurvntyktcqhfeg9y...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" One problem in *Programming Haskell from First Principles* confuses me. (So far.) It's one where you start with the declaration and binding i :: Num a => a i = 1 (which of course works because Num a => a is the type of 1) and then change the declaration to i :: a and first try to predict and then see what happens. It fails, with ghci suggesting that you put the Num a => back. That seemed reasonable at first, but then I considered this: - id has type a -> a, and if you try to evaluate id 1 it works without complaint. - In all the work I've done on compilers, parameter passing has effectively been assignment of actual parameters to the corresponding formal parameters. In Haskell, that might mean passing along the appropriate thunk, but the principle is the same, isn't it? So, if I can't bind 1 to i which is declared to have type a, why can I successfully pass 1 to id? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190722/52efee62/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 22 Jul 2019 20:44:47 -0700 From: Ramnath R Iyer <r...@silentyak.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] binding vs. parameter passing Message-ID: <CACL-FmxSh6zF8-qO9o8GcMZ9x1M2Kcbf_+Es57r=8xh6_zv...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" This answer is likely incomplete at best and wrong at worst, but I'll give it a shot. When you have this type declaration: i :: a It means that you are declaring the symbol i that can be slotted into any location that requires an a. It is a task for the compiler to process the overall program specification and infer that a has a particular concrete type. When the program is specified though, the value i has a generic type with no bounds, and the only way to *construct* such a value is to supply a value of type a from somewhere else. The problem here is not that you can't *bind* 1 to i, but that you cannot *construct* any value of type a. A direct analog of this would be - not the application of the id function as you called out - but that you cannot define a function with the following signature, not including bottom: f :: a -> b The reason is that you can't supply a value of type b. I have some experience with Java, and it has a similar constraint that generic types cannot be instantiated. -- RRI On Mon, Jul 22, 2019 at 7:30 PM James Jones <jejones3...@gmail.com> wrote: > One problem in *Programming Haskell from First Principles* confuses me. > (So far.) > > It's one where you start with the declaration and binding > > i :: Num a => a > i = 1 > > (which of course works because Num a => a is the type of 1) and then > change the declaration to > > i :: a > > and first try to predict and then see what happens. It fails, with ghci > suggesting that you put the Num a => back. That seemed reasonable at > first, but then I considered this: > > - id has type a -> a, and if you try to evaluate id 1 it works without > complaint. > - In all the work I've done on compilers, parameter passing has > effectively been assignment of actual parameters to the corresponding > formal parameters. In Haskell, that might mean passing along the > appropriate thunk, but the principle is the same, isn't it? > > So, if I can't bind 1 to i which is declared to have type a, why can I > successfully pass 1 to id? > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- Ramnath R Iyer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190722/0967989c/attachment-0001.html> ------------------------------ Message: 3 Date: Tue, 23 Jul 2019 00:01:06 -0500 From: Miguel Angel Ordoñez Silis <miano...@ciencias.unam.mx> To: beginners@haskell.org Subject: [Haskell-beginners] Stack doesn't find downloaded module Message-ID: <CAM4F45qHKBdC-eyxV4emFpnhE5abFW=b1nqqucxfm5ovams...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi! I downloaded the following package https://www.stackage.org/lts-13.29/package/multiset-0.3.4.1 using the following cli (Linux) command: stack install multiset. It was supposedly successfully installed but when I try to import it stack says it couldn't find it ('Could not find module ‘Data.MultiSet’). I've tried reading haskellstack.org's documentation but I've not been able to find a solution. Well, thanks in advance for your help Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190723/c6bb4cc2/attachment-0001.html> ------------------------------ Message: 4 Date: Tue, 23 Jul 2019 08:03:03 +0200 From: Norbert Melzer <timmel...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Stack doesn't find downloaded module Message-ID: <ca+bcvsvyw74bt4fnf6hbqguj_mdmqyqfboepsbjhh2xk6tq...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello Miguel! On Tue, Jul 23, 2019 at 7:01 AM Miguel Angel Ordoñez Silis < miano...@ciencias.unam.mx> wrote: > stack install multiset. > `stack install` is meant to install packages that result in a executable program, not for libraries. > It was supposedly successfully installed but when I try to import it stack > says it couldn't find it ('Could not find module ‘Data.MultiSet’). I've > tried reading haskellstack.org's documentation but I've not been able to > find a solution. > You need to specify `multiset` as a dependency in your `package.yaml` of your project. > > Well, thanks in advance for your help > > Mike > > _______________________________________________ > 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/20190723/32cb87ed/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 133, Issue 3 *****************************************