| |
comp.lang.haskell |
Dirk Thierbach schrieb: >>> I would expect >>> reads "1.2" :: [(Int,String)] >>> to be evaluated to >>> [(1,".2")] >>> but using Hugs (Version Sep 2006) it is just >>> [] >>> Bug or feature? >> Good question. GHCi, version 6.8.2, agrees with Hugs. > The reason at least in GHC is that all numeric instances use the same :type 1e2 parseTree "'a'.'b'.'c'.'d'" :: (Tree Char) parseTree "1.2.3.4" :: (Tree Float) but parseTree "1.2.3.4" :: (Tree Int) You can't parse a tree of type String as well (without escape codes),
>> Frank Poettgen <Frank.Poett...@Post.RxWyTxH-AyAzCyHzEyN.de> writes:
> function to parse the string. The string is then converted, unless
> conversion fails.
>> reads "1e2" :: [(Int,String)]
> [(100,"")]
100.0 :: Fractional a => a
> strongly suspect "feature". But I never noticed that before, too.
a binary infix symbol describing the branching of a tree of arbitrary
type. Then one gets e.g.
/\
/\d
/\c
ab
/\
/ \
1.2 3.4
no parse
but that's obvious.