[Haskell-cafe] Why this cannot be compiled?
Magicloud Magiclouds
magicloud.magiclouds at gmail.com
Mon Jul 13 02:45:00 EDT 2009
Hi,
The following code failed to compiled, with error:
Attribute.hs:46:91:
Couldn't match expected type `[t]'
against inferred type `(a, String)'
In the expression: (color_, rest_)
In a case alternative: [(color_, rest_)] -> (color_, rest_)
In the expression:
case reads rest1 of {
[(color_, rest_)] -> (color_, rest_)
_ -> (Color 0 0 0, rest1) }
43 instance Read Attribute where
44 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) <- lex str
45 , (color, rest)
<- case reads rest1 of
46
[(color_, rest_)] -> (color_, rest_)
47
_ -> (Color 0 0 0, rest1) ]
48 where mkAttr "AttrFgColor" color = AttrFgColor color
49 mkAttr "AttrBgColor" color = AttrBgColor color
50 mkAttr "AttrInverse" _ = AttrInverse
51 mkAttr "AttrWeak" _ = AttrWeak
52 mkAttr "AttrUnderline" _ = AttrUnderline
--
竹密岂妨流水过
山高哪阻野云飞
More information about the Haskell-Cafe
mailing list