0

Hi I am trying to run a custom monad by using prelude as suggested here:Calling a custom monad in haskell using the bind , by using Prelude Control.Monad> runCustomM cm "foo"

However when I try to do the import Control.Monad nothing happens an the prompt type doesn't change. Likewise nothing happens when I use the System.IO as suggested here: https://downloads.haskell.org/~ghc/8.4.2/docs/html/users_guide/ghci.html

How can I execute the prelude correctly s.t. I can execute my own Monads?

I tried

Loaded package environment from C:\Users\tqx98\AppData\Roaming\ghc\x86_64-mingw32-9.0.1\environments\default
GHCi, version 9.0.1: https://www.haskell.org/ghc/  :? for help

ghci> import Control.Monad
ghci> import System.IO 
ghci> 

The above is more or less all that happens.

Piskator
  • 605
  • 1
  • 9

1 Answers1

3

When I try to do the import Control.Monad nothing happens an the prompt type doesn't change.

This appears to be the expected behaviour in your version of GHCi, see the documentation of v9.0.1 (contrasting with that of v8.4.2 which you linked). In my experience, the long prompt was quite annoying when importing a lot of modules, so I'd consider it an improvement.

It just be working just fine to call the functions from the imported modules.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
  • ahh... but how do I then execute a customized Monad, if the Control.Monad is already activiated. Do you know how I execute my custom monad, such as I requested in the linked post: https://stackoverflow.com/questions/73727177/calling-a-custom-monad-in-haskell-using-the-bind/73727764?noredirect=1#comment130318342_73727764 ? – Piskator Sep 24 '22 at 15:06
  • You don't actually need to import `Control.Monad` for that, if you did define the `newtype CustomM a = CustomM {runCustomM:: a -> String}` in your ghci session (or `:load` the definition from a file) the `runCustomM` function already is in scope. – Bergi Sep 24 '22 at 15:17
  • 1
    You might want to extend your question with the full transcript of the ghci session you ran and the error you got – Bergi Sep 24 '22 at 15:18