3

I get an error when I use the following Haskell code inside Hamlet Yesod:

#{show $ (read "True" :: Bool)}

It seems it doesn't accept ':' characters, but I actually need it.

The error is the following:

Handler/Game.hs:85:11:
    Exception when trying to run compile-time code:
      "#{show $ read "True" :: Bool}" (line 1, column 25):
unexpected ":"
expecting "}"

Is it possible to bypass this error and be able to use Prelude.read?

kolam
  • 731
  • 4
  • 17
  • Though I am not familiar with Yesod, that seems redundant. The expression within the braces is equivalent to `"True"`. Applying `read` and then `show` is in most cases a no-op. – duplode Oct 17 '13 at 19:43
  • 3
    Usually you don't need to call any functions inside a view, leave it to a controller or a model and store it in a variable. If you really want, you can use as-functions from `classy-prelude` of define it yourself, i.e. `asBool = id :: Bool -> Bool`. – swish Oct 17 '13 at 19:53
  • @duplode I know it's redondant. I just used as an example for the error. – kolam Oct 18 '13 at 15:25

0 Answers0