追い討ちReal World HaskellのP.245 10.4 暗黙の状態
じゃってことで
runParse関数の型を
runParse :: ParseState -> Either String (a, ParseState)
から
runParse :: Parse a -> ParseState -> Either String (a, ParseState)
に変えて:loadするとどうなるか?
Prelude> :load Parse.hs [1 of 1] Compiling Main ( Parse.hs, interpreted ) Parse.hs:18:26: Couldn't match expected type `ParseState -> Either String (a, ParseState)' against inferred type `Either a1 (a, Parse a)' In the expression: Right (a, s) In the first argument of `Parse', namely `(\ s -> Right (a, s))' In the expression: Parse (\ s -> Right (a, s)) Parse.hs:21:47: Couldn't match expected type `Parse a' against inferred type `ParseState' In the second argument of `runParse', namely `(ParseState initState 0)' In the expression: runParse parser (ParseState initState 0) In the expression: case runParse parser (ParseState initState 0) of { Left err -> Left err Right (result, _) -> Right result } Failed, modules loaded: none.
どないやねん、マジで!
まったくの謎・・・