id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,testcase,blockedby,blocking,related,differential,wikipage
67,Signature context in recursive groups,nobody,nobody,"{{{
Hello,
I have a problem with signature contexts in mutually
recursive groups. I want to write a scanner, which is
able to read inputs of the form ""int(3)"" or
""float(2,0)"" and return corresponding values of the
datatype:
data Token = TInt Int
| TFloat Float
deriving (Read,Show)
Both constructors have the same type. Therefore, I want
to pass them to another function, which reads the
corresponding number with the function reads:
scan :: String -> [Token]
scan ('i':'n':'t':str) = scanNumber TInt str
scan ('f':'l':'o':'a':'t':str) = scanNumber TInt str
scanNumber :: Read a => (a -> Token) -> String ->
[Token]
scanNumber tokenCons ('(':str) = case reads str of
((n,(')':str1)):_) -> tokenCons
n:scan str1
_ -> error ""no literal""
main = print (scan ""int(4)"")
In Hugs this program works fine, but ghc does not
accept it, because of a mutually recursive group. Is
this a feature or a bug?
What does the Haskell 98 standard say?
Thanks and regards,
Frank Huch
}}}",bug,closed,normal,,Compiler (Type checker),5.0,Wont Fix,,,,,None/Unknown,,,,,,