为什么我可以使用这个"私有"值构造函数?

sta*_*ser 2 haskell

我把它放在Shapes.hs中:

module Shapes   
( Shape(Rectangle)
) where 

data Shape = Circle | Rectangle deriving (Show)
Run Code Online (Sandbox Code Playgroud)

然后我进入GHCi并加载它:l Shapes.

打字Circle工作.我只Rectangle在paranthesis中指定,为什么它有效?

ram*_*ion 5

这是使用的副作用:load.如果你改为使用

ghci> :m +Shapes
Run Code Online (Sandbox Code Playgroud)

要么

ghci> import Shapes
Run Code Online (Sandbox Code Playgroud)

你将无法访问Circle构造函数.