类型:
data Type
= Ttype
| Arr Type Type
deriving (Eq, Show)
data Ttype = String
我的代码:
lchar = lexeme . char
parens :: ParserT a b -> ParserT a b
parens = between (lchar '(') (lchar ')')
symbol :: String -> ParserT a String
symbol p = string p <* spaces
typeParser :: CharParser () Type
typeParser = arr <|> tbool <|> tbool
where tbool = Ttype <$> (show tbool)
subtyp = parens arr <|> tbool <|> tbool
arr = chainr1 subtyp $ try (symbol "->" *> pure Arr)
parseIt :: String -> Either ParseError Type
parseIt = P.parse typeParser ""
如何解析此类型:(A->(B-> C)) - &gt;(A-> B) 抱歉。我是Haskell语言的新手。