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: type variables (Thomas) ---------------------------------------------------------------------- Message: 1 Date: Tue, 24 Aug 2010 22:25:36 +0200 From: Thomas <hask...@phirho.com> Subject: Re: [Haskell-beginners] type variables To: beginners@haskell.org Message-ID: <4c742ac0.5090...@phirho.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Thank you Brent, Daniel & Jürgen! Got it. Actually it seems obvious now. I guess my misleading expectations of what type variables are made me sort of blind... Again: Thanks, Thomas On 24.08.2010 14:47, Brent Yorgey wrote: > On Tue, Aug 24, 2010 at 01:09:56PM +0200, Thomas wrote: >> >> But if I change the type declaration of 'testFold' to: >> testFold :: XMLCallback a >> it will not compile. >> >> I thought that 'a' is a type /variable/ thus able to hold any type, >> for example, but not limited to '[(XMLTreeNode, [Int], >> [XMLTreeNode])]'. Why do I need to be that much more specific in the >> declaration for 'testFold'? > > Daniel has already given a more detailed answer, but just to emphasize > the main point a bit more: > > testFold :: XMLCallback a > > means that testFold *should work no matter what a is*. But as Daniel > has explained, this is not the case; testFold only works for certain > specific types in place of a. Type variables are not a shortcut used > when one can't be bothered to give the type in more detail; rather, > they are strong assertions that *any type will work*. > > -Brent > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 26, Issue 49 *****************************************