gpt4 book ai didi

haskell - 为什么我可以使用这个 "private"值构造函数?

转载 作者:行者123 更新时间:2023-12-01 22:40:45 25 4
gpt4 key购买 nike

我把它放在 Shapes.hs 中:

module Shapes   
( Shape(Rectangle)
) where

data Shape = Circle | Rectangle deriving (Show)

然后我进入 GHCi 并使用 :l Shapes 加载它。

输入Circle有效。我只在括号中指定了矩形,那么为什么它会起作用呢?

最佳答案

这是使用 :load 的副作用。如果您改为使用

ghci> :m +Shapes

ghci> import Shapes

您将无法访问 Circle 构造函数。

关于haskell - 为什么我可以使用这个 "private"值构造函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23409916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com