I am following this post about the reader monad in Haskell.
It starts with the definition:
load :: Config -> String -> IO String
load config x -> readFile (config ++ x)
Where Config is a type alias for String and it represents a directory name.
The method is meant to display on screen the content of a file, for example "./myFile.txt".
I run this method from ghci with:
load "./" "myFile.txt"
The second example introduces the reader monad:
load :: (MonadReader Config m, MonadIO m) => String -> m String
load x = do
config <- ask
liftIO $ readFile (config ++ x)
Question is: how do I run it from ghci?
I have tried with things like:
(runReader load "myFile.txt") "./"
but no joy.
What is the command that loads ./myFile.txt?
runReaderT (load "myFile.txt") "./" :: IO String