
sometimes i have copied a typedef from a tutorial or demo and get errors. i take the typedef out and the program runs fine. i don't think the problem lies with the person creating the typedef because they are very experienced. is it possible that the matter has to do with the interpreter eg hugs vs ghci and such? or possibly an update of the syntax over time? for instance, i'm going through rex page's "two dozen short lessons in haskell" from uni of oklahoma. they use hugs and the error message for reverse 'x' is completely different from what i get using ghci. -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's

On Saturday 26 June 2010 21:27:20, prad wrote:
sometimes i have copied a typedef from a tutorial or demo and get errors. i take the typedef out and the program runs fine.
Then ask ghci what the type is, e.g. Prelude> :t reverse reverse :: [a] -> [a]
i don't think the problem lies with the person creating the typedef because they are very experienced.
Maybe, maybe not.
is it possible that the matter has to do with the interpreter eg hugs vs ghci and such? or possibly an update of the syntax over time?
Unlikely for simple functions. For advanced stuff that requires extensions, that can happen.
for instance, i'm going through rex page's "two dozen short lessons in haskell" from uni of oklahoma. they use hugs and the error message for
reverse 'x'
is completely different from what i get using ghci.
ghc and hugs give very different error messages, but it boils down to the same: hugs: Hugs> reverse 'x' ERROR - Type error in application *** Expression : reverse 'x' *** Term : 'x' *** Type : Char *** Does not match : [a] ghci: Prelude> reverse 'x' <interactive>:1:8: Couldn't match expected type `[a]' against inferred type `Char' In the first argument of `reverse', namely 'x' In the expression: reverse 'x' In the definition of `it': it = reverse 'x' Both say that you passed an argument of type Char to a function which works on lists (of any type).

On Saturday 26 June 2010 21:27:20, prad wrote:
for instance, i'm going through rex page's "two dozen short lessons in haskell" from uni of oklahoma.
Wow, that's even pre-Haskell98. It refers to the Haskell-1.3 report. There have been many changes in the language since then. It might have become pretty unusable by now, perhaps you should try another tutorial (YAHT [although that is quite old too, many of the function it says are in the Prelude aren't anymore] or LYAH for example).

On Sat, 26 Jun 2010 22:18:35 +0200
Daniel Fischer
It refers to the Haskell-1.3 report. There have been many changes in the language since then.
ok thx for the warning. i'm starting to notice some issues. also thx for the tips in your other post daniel. here's a specific item i was referring to: ndmPapers :: IO () ndmPapers = do tags <- fmap parseTags $ openURL "http://community.haskell.org/~ndm/downloads/" let papers = map f $ sections (~== "<li class=paper>") tags putStr $ unlines papers where f :: [Tag] -> String f xs = fromTagText (xs !! 2) http://community.haskell.org/~ndm/darcs/tagsoup/tagsoup.htm at the bottom of the page: my papers (neil mitchell who wrote tagsoup for haskell) with the f :: [Tag] -> String left in ghci croaks: ====== TagSoup.hs:66:14: `Tag' is not applied to enough type arguments Expected kind `*', but `Tag' has kind `* -> *' In the type signature for `f': f :: [Tag] -> String In the definition of `ndmPapers': ndmPapers = do { tags <- fmap parseTags $ openURL "http://community.haskell.org/~ndm/downloads/"; let papers = ...; putStr $ unlines papers } where f :: [Tag] -> String f xs = fromTagText (xs !! 2) Failed, modules loaded: none. ====== (i'm guessing that Tag is some type defined in Text.HTML.TagSoup) however, the program runs fine if i comment out the type def. so i'm curious as to why this is so. i can't do a :t on f getting a 'not in scope' error, i guess because it is part of ndmPapers, but that seems strange to me. -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's

On Sunday 27 June 2010 00:35:27, prad wrote:
with the f :: [Tag] -> String left in ghci croaks:
====== TagSoup.hs:66:14: `Tag' is not applied to enough type arguments Expected kind `*', but `Tag' has kind `* -> *' In the type signature for `f': f :: [Tag] -> String In the definition of `ndmPapers': ndmPapers = do { tags <- fmap parseTags $ openURL "http://community.haskell.org/~ndm/downloads/"; let papers = ...; putStr $ unlines papers } where f :: [Tag] -> String f xs = fromTagText (xs !! 2) Failed, modules loaded: none. ====== (i'm guessing that Tag is some type defined in Text.HTML.TagSoup)
however, the program runs fine if i comment out the type def.
so i'm curious as to why this is so.
Neil changed the kind of Tag in tagsoup-0.8, until version 0.6, it was data Tag = TagOpen String [Attribute] | TagClose String | TagText String | TagComment String | TagWarning String | TagPosition !Row !Column and it became data Tag str = TagOpen str [Attribute str] | TagClose str ... in 0.8, I think the reason was to allow the use of ByteStrings and Data.Text in addition to plain String. It would also work with f :: [Tag String] -> String
i can't do a :t on f getting a 'not in scope' error, i guess because it is part of ndmPapers, but that seems strange to me.
It would be very nice if one could query the type of local definitions.
participants (2)
-
Daniel Fischer
-
prad