[Haskell-beginners] Re: type def messes up

Daniel Fischer daniel.is.fischer at web.de
Sat Jun 26 18:53:18 EDT 2010


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.



More information about the Beginners mailing list