Ad
  • Custom User Avatar

    I am getting this error when I try to attempt a solution:

    Postfix/Tests.hs:23:28: No instance for (Integral t0) arising from a use of 'begin' The type variable 't0' is ambiguous Relevant bindings include x :: t0 (bound at Postfix/Tests.hs:23:19) Note: there are several potential instances: instance Integral GHC.Int.Int16 -- Defined in 'GHC.Int' instance Integral GHC.Int.Int32 -- Defined in 'GHC.Int' instance Integral GHC.Int.Int64 -- Defined in 'GHC.Int' ...plus 9 others In the first argument of '(==)', namely 'begin push x push y push z end' In the expression: begin push x push y push z end == (z :: Int) In the second argument of '($)', namely '\ x y z -> begin push x push y push z end == (z :: Int)'

    It's quite similar to the one that Mr.eod ran into. I am not sure where the bug is located and I could reproduce that in my PC. Since I used the typeclass method, I have to give each parameter the type "(Integral i) => i" to make sure it can catch every valid stmt (Otherwise, ghc refuses to run instruction like begin push 1 end because ghc cannot ensure whether 1 has the type of Int or not).

    Does the error log means I cannot use Integral? What should I do?

  • Custom User Avatar

    Wrapping (==) in a lambda, reinventing zipWith and converting the Foldable to a List. Also, spurious imports (well, one).

    Awfully sorry, but I fail to see how this is a Best Practice. (toList is practically a cheat in my unhumble opinion.)

    Also, no Bonus Points .. :/