jgm/pandoc2 — Issue #3: fromRoman
Author: michaelt
Created: 2011-11-08 07:13:51+00:00
State: open

It came to me this morning that maybe the warning in Shared.hs arises from -XOverloadedStrings. This seems true. I don't know if it is a bug in the extension, or more likely a subtlety it introduces. Indeed if you strike any line from the module:

{-#LANGUAGE OverloadedStrings#-}
go :: String -> String -> Maybe Int
go "M" ('M':xs) = fmap (+ 1000) $ go "M" xs
go "CM" ('C':'M':xs) = fmap (+ 900) $ go "C" xs

you don't get the warning. Why this is I still can't figure. If you strike the signature this one is inferred:

go :: (Data.String.IsString a, Num b, Functor f, Eq a) => a -> [Char] -> f b

That suggests you could coherently import Data.Text and change the signature to

go :: Text -> String -> Maybe Int

and indeed then there is no problem, though you'd think it would have any pattern match issues that `String -> String -> Maybe Int` has, Text -> String -> Maybe Int also has. Am I wrong that the appearance that we are 'pattern matching' on Texts is some clever illusion, since we don't know the constructors? The warning somehow comes from the overlap of two ways of interpreting them, only forcing the genuine constructor form 'X':'Y':[] can you get rid of it. --Something like that.