0

So I have defined a function like this one below:

myFunction :: String -> Either String MyType

I am reading String until the end. Left is used for handling errors. Right suppose to return me the tuple. In myFunction I am calling anotherFunction and checking if it returns Left or Right like this:

myFunction :: String -> Either String MyType
myFunction "" = Right -- want to return MyType here
myFunction s = 
     case anotherFunction s of
         Left c -> Left c
         Right (v1, v2, t) -> -- want to call myFunction again with t

When anotherFunction returns Right, I want to call myFunction again recursively without loosing v1 and v2. How can I achieve that with recursion?

Here is the exact definition of MyType:

data MyType = MyString String | MyInt Int | MyMap [(String, MyType)] deriving (Show, Eq)
dekanidze
  • 132
  • 2
  • 9

0 Answers0