24-days-of-purescript-2016 icon indicating copy to clipboard operation
24-days-of-purescript-2016 copied to clipboard

Error in code for day 4

Open FranklinChen opened this issue 7 years ago • 1 comments

Day 4 has a link to http://try.purescript.org/?gist=ec91ebe17ca510f1ca36c8a535b292ac but that generates

No type class instance was found for

    Control.Monad.Error.Class.MonadThrow String
                                         (App
                                            ( console :: CONSOLE
                                            | eff4
                                            )
                                         )


while applying a function throwError
  of type MonadThrow t1 t2 => t1 -> t2 t3
  to argument "Out of range!"
while checking that expression throwError "Out of range!"
  has type t0 Unit
in value declaration example

where eff4 is a rigid type variable
        bound at line 24, column 1 - line 27, column 22
      t0 is an unknown type
      t1 is an unknown type
      t2 is an unknown type
      t3 is an unknown type

FranklinChen avatar Jun 23 '17 17:06 FranklinChen

Looks like you need to add

derive newtype instance monadThrowApp :: MonadThrow String (App eff)

since we refined MonadError.

paf31 avatar Jun 23 '17 18:06 paf31