I'm trying to write a parser in Haskell.
This parser take a string (example: "abc def") in parameter and return a Maybe (String, String).
Maybe (String, String)
First String get characters while it's number or letter.
Second String get the rest
In this example, I want to return Maybe ("abc", " def").
parseString :: String -> Maybe (String, String)
parseString "" = Nothing
parseString expr = case isString expr of
Just (char, rest) -> fmap (char:) (parseString rest)
Nothing -> Just ("", expr)
isString return :
Maybe (Char, String) -> Char = first character, String = rest / Nothing if isn't a letter or digit.
The problem, I can not return the rest of my String in the maybe.