A Haskell interpreter /w type definitions
Asked Answered
B

2

7

Is there a Haskell interpreter that accepts type definitions or preferably all kinds of statements?

I've already tried ghci and hugs and none of these does that. Is there some particular reason that this is hard/impossible?

Biota answered 11/10, 2011 at 9:10 Comment(3)
What are you trying to do? Though I think HBC was able to accept arbitrary Haskell statements. Note that you can't just provide a type definition on its own in ghci as there won't be an attached function for it, though let f x = x + 1 :: (Num a) => a -> a should work.Emblazonment
I share your pain. I have tons of Test.hs hanging around. Even worse, the ghci console doesn't deal with paste action correctly, at least on my system (bug I just reported).Inextirpable
@Emblazonment Actually, at this moment I'm just starting out and not yet trying to do anything particular. Just got me wondering.Biota
L
3

Traditionally, the answer to this has been that code written at an interactive prompt lives inside the IO monad. It's as if there's a shadow main = do hiding behind the Prelude>. Think about it that way, and the absence of type declarations and top level declaration syntax makes sense, as do all the let statements.

But Ptival is right: it looks like we won't have to worry about any of that soon.

Lumpen answered 11/10, 2011 at 20:7 Comment(0)
F
13

It seems that it will soon be fixed in GHCi, see:

https://ghc.haskell.org/trac/ghc/ticket/4929

Ferrante answered 11/10, 2011 at 9:21 Comment(1)
Indeed. It's already possible in HEAD, and the feature will be in 7.4.Endocarp
L
3

Traditionally, the answer to this has been that code written at an interactive prompt lives inside the IO monad. It's as if there's a shadow main = do hiding behind the Prelude>. Think about it that way, and the absence of type declarations and top level declaration syntax makes sense, as do all the let statements.

But Ptival is right: it looks like we won't have to worry about any of that soon.

Lumpen answered 11/10, 2011 at 20:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.