Haskell解释器/w类型定义。

时间:2022-10-15 19:19:15

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

是否有一个Haskell解释器接受类型定义,或者最好是所有类型的语句?

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

我已经尝试过ghci和hugs,但没有一个这样做。有什么特别的原因吗?

2 个解决方案

#1


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.

传统上,这个问题的答案是,写在交互式提示上的代码住在IO monad里面。就好像有一个影子主=隐藏在序幕>后面。这样想,没有类型声明和*声明语法是有意义的,就像所有的let语句一样。

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

但是Ptival是对的:看起来我们很快就不用担心这些了。

#2


13  

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

它似乎很快就会被固定在GHCi,看:

http://hackage.haskell.org/trac/ghc/ticket/4929

http://hackage.haskell.org/trac/ghc/ticket/4929

#1


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.

传统上,这个问题的答案是,写在交互式提示上的代码住在IO monad里面。就好像有一个影子主=隐藏在序幕>后面。这样想,没有类型声明和*声明语法是有意义的,就像所有的let语句一样。

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

但是Ptival是对的:看起来我们很快就不用担心这些了。

#2


13  

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

它似乎很快就会被固定在GHCi,看:

http://hackage.haskell.org/trac/ghc/ticket/4929

http://hackage.haskell.org/trac/ghc/ticket/4929