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. Working out the types (Patrick LeBoutillier) 2. Re: Working out the types (Daniel Fischer) 3. Re: Understandig types (Michael Xavier) ---------------------------------------------------------------------- Message: 1 Date: Tue, 5 Jul 2011 13:55:43 -0400 From: Patrick LeBoutillier <patrick.leboutill...@gmail.com> Subject: [Haskell-beginners] Working out the types To: beginners <beginners@haskell.org> Message-ID: <cajcqsbhnu7fvcndfce5rs26oleiqnx4rodeafhjjoxk7c61...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi all, Today after reading a question on StackOverflow I found myself "working out the types" for this expression: map . (:) Using a pencil and paper (and more time than I has hoped) I was able to come to the same answer as given by ghci: map . (:) :: a -> [[a]] -> [[a]] Here's my question: Does ghci have a verbose mode or something where is can show you step by step how the types are worked out? If not is there a hackage (or any other kind of) package that can do that? I've seen long examples worked out by people on this list (namely Daniel Ficher) and they are easy to follow and help me a lot, so I was wondering if such a program existed that could do it automatically. Thanks, Patrick -- ===================== Patrick LeBoutillier Rosem?re, Qu?bec, Canada ------------------------------ Message: 2 Date: Tue, 5 Jul 2011 21:24:10 +0200 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] Working out the types To: beginners@haskell.org Message-ID: <201107052124.10734.daniel.is.fisc...@googlemail.com> Content-Type: Text/Plain; charset="iso-8859-1" On Tuesday 05 July 2011, 19:55:43, Patrick LeBoutillier wrote: > Hi all, > Here's my question: Does ghci have a verbose mode or something where > is can show you step by step how the types > are worked out? No. You can use it to get the types of subexpressions, though, and work towards the complete expression from that: Prelude> :t (:) (:) :: a -> [a] -> [a] Prelude> :t (. (:)) (. (:)) :: (([a] -> [a]) -> c) -> a -> c Prelude> :t (map . (:)) (map . (:)) :: a -> [[a]] -> [[a]] which gives you smaller gaps to fill in. > If not is there a hackage (or any other kind of) > package that can do that? I'm not aware of any, but there might be. > > a lot, so I was wondering if such a program existed that could do it > automatically. Automatic type checkers do exist (every compiler/interpreter needs one), but I don't think they have been written with the ability to output not only the result but also the derivation. For someone familiar with a particular type checker, it probably wouldn't be hard to add that feature, but if it's a complicated beast like GHC's type checker, becoming familiar with it would probably be a big undertaking. Writing your own much-reduced (able to parse and typecheck only a very restricted subset of the language) might be easier, but probably working from Mark P. Jones' "Typing Haskell in Haskell" http://web.cecs.pdx.edu/~mpj/thih/ would be better than starting from scratch (it's somewhat oldish, so it certainly doesn't cope with recent GHC extensions, but for everyday run-of- the-mill problems, it should be working with only minor modifications). ------------------------------ Message: 3 Date: Tue, 5 Jul 2011 18:35:54 -0700 From: Michael Xavier <nemesisdes...@gmail.com> Subject: Re: [Haskell-beginners] Understandig types To: Jared Hance <jaredha...@gmail.com> Cc: beginners@haskell.org Message-ID: <CANk=zmGxLM40pwtrwxxbDe=ohvd8d8tkddq6deavzdt_xxb...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" > No. [Char] is a list, not array, of Char. That is, something like My bad. I let my Ruby mind take over. In Ruby, the most basic list-like structure is an array, which shares some similarities with Haskell's list ( O(1) lookups not being one of them). -- Michael Xavier http://www.michaelxavier.net -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110705/22e3dab9/attachment-0001.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 37, Issue 9 ****************************************