Evan Laforge wrote: >> hex2 = (+)<$> ((*16)<$> higit)<*> higit >> higit = subtract (fromEnum '0')<$> satisfy isHexDigit >> color = Color<$> hex2<*> hex2<*> hex2
Twan van Laarhoven wrote: > How is "subtract (fromEnum '0')" supposed to convert a hex digit to an Int > or Word8? I think you need digitToInt (or an equivalent function) for that. Right. How about: color = Color <$> hex2 <*> hex2 <*> hex2 hex2 = mkHex2 <$> hexit <*> hexit hexit = satisfy isHexDigit mkHex2 h1 h0 = fst . head $ readHex [h1, h0] Or, if you are fanatic about safety like I am, you might even write: mkHex2 h1 h0 = maybe 0 fst . listToMaybe $ readHex [h1, h0] Regards, Yitz _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
