How do I start tracing from Purescript psci?

I'm still learning the basics of Purescript and I can get trace

to work with functions main

, but how to play with it in psci? Here is what I have tried with no success and I cannot figure out why it is not working.

> import Debug.Trace
> trace "aloha"
Error in module $PSCI:
Error in value declaration main:
Error at  line 1, column 5 - line 1, column 15:
  No instance found for Prelude.Show (Control.Monad.Eff.Eff (trace :: Debug.Trace.Trace | u12) Prelude.Unit)
See https://github.com/purescript/purescript/wiki/Error-Code-NoInstanceFound for more information, or to contribute content related to this error.

      

+3


source to share


1 answer


psci

can only do clean calculations at the moment, but that will change when version 0.7 is released and you can run your command.

Now, if you need to perform actions Eff

from psci

, you can do it using unsafe functions:



> import Control.Monad.Eff
> import Control.Monad.Eff.Unsafe
> import Debug.Trace

> runPure (unsafeInterleaveEff (trace "Hello World!"))
Hello World!
Unit {}

      

Here we inadequately convert the action Eff

given trace

to a computation Pure

and use runPure

it to get the value. This is what psci

will automate in 0.7, but for now you have to do it manually, unfortunately.

+3


source







All Articles