ghc - Use Haskell through GHCI alone? -
i'm totally new haskell, soft question, seems tutorials haskell define main function, compile it, , execute program whole command line.
i'm coming more of r/julia/python background feel comfortable working within repl or sending lines repl editor.
i'm wondering if possible haskell programmer using ghci alone? having difficult following of tutorials on haskell within interpreter reason. code written executed within interpreter different code compiled i.e. interpreter require special syntax?
tl; dr
in order use ghci, definitions (... = ...
) must prefixed let
- e.g let ... = ...
.
ghci have subtly different syntax regular haskell. accommodate use of io in repl.
for part, syntax of ghci same syntax do
block in io monad: definitions can made via let
syntax:
let f x = 10
and io actions can sequenced:
print 1
when submitted ghci, performed - i.e let
definitions bound , io actions performed.
however, subtle differences come ghci's other function: evaluation expressions. if type in expression not io action, instance:
1 + 3
ghci attempt print result of expression. i.e, execute:
print $ 1 + 3
Comments
Post a Comment