Is it possible to export constructors for pattern matching, but not for construction, in Haskell Modules?

前端 未结 3 532
予麋鹿
予麋鹿 2020-12-05 07:03

A vanilla data type in Haskell has zero or more constructors, each of which plays two roles.

In expressions, it supports introduction, its a function from zero or mo

3条回答
  •  萌比男神i
    2020-12-05 07:15

    You cannot. But if there are only reasonable number of constructors for your type T, you may want to hide the constructors and instead provide a function which does the pattern matching in the same spirit as maybe :: b -> (a -> b) -> Maybe a -> b.

提交回复
热议问题