I think you are making a common rookie mistake, confusing what you can write inside the repl of ghci and what you write in a haskell source file.
All sml interpreters are made in such a way that you can write any top level declaration into the repl, or put in other words: anything you can write in an sml file, you can write into the sml interpreter. Thus you are allowed to write val foo = "bar"
into a file and use C-c C-b
to load the file and you are allowed to just put in val foo = "bar"
into the interpreter.
On the other hand, because of how haskell work, you can write let foo = 42
into ghci, however it is not a valid top level declaration and thus this can't be in a haskell source file (by it self). On the other hand you can have id n = n
in a haskell source file and use C-c C-l
to load the file, however you can't write this directly into ghci (you will get an error: :1:6: parse error on input '='). The reason for this is that the repl in ghci runs in the IO monad, and thus what ever you write into ghci must be done using the do notation. I can only recommend that you read Interactive evaluation at the prompt from the Using GHCi user guide.
C-c C-b
in sml-mode is the exact same thing as C-c C-l
in haskell-mode, well atleast conceptually. I don't know that much about the internals of haskell-mode, but in sml-mode C-c C-b
executes some sml code in the interpreter, normally the use(...)
function. In haskell-mode it seems to just excute the :load "..."
ghci command