为什么我不能在 GHCi 中定义类型?
Prelude> data MyBool = T | F
<interactive>:1:0: parse error on input `data'
GHCi is a very simple REPL which reads expressions and prints results (usually), and can be imagined as an interactive do
expression. The problem with allowing general Haskell constructs is (a) how to merge them into an already loaded program, (b) what to do with them on reload or other action that resets the state of the REPL. Additionally, there are questions about what to do when a definition conflicts with something already defined. And then there's the simple fact that the current implementation is simply an expression evaluator, whereas compiling new code is rather more involved.