I’m struggling with converting a Right String. I have a method called getEval which evaluates a math expression (a String basically), and I get it back as follows:
*Main> getEval "3+6"
Right "9"
the type of getEval is
*Main> :t getEval "3+6"
getEval "3+6"
:: (Functor m, Control.Monad.CatchIO.MonadCatchIO m) =>
m (Either InterpreterError String)
getEval looks like this:
getEval str = runInterpreter $ setImports ["Prelude"] >> eval str
If it matters, getEval uses the eval in Haskell’s hint library (Language.Haskell.Interpreter) to do the actual parsing and calculation.
How can I get this into a float?
1 Answer