Record syntax default value for accessor

后端 未结 2 1128
野的像风
野的像风 2021-01-11 21:29

As I was writing up an answer just now, I ran across an interesting problem:

data Gender = Male | Female
            deriving (Eq, Show)

data Age = Baby | C         


        
2条回答
  •  -上瘾入骨i
    2021-01-11 22:26

    Is there a way to both take advantage of record syntax, and also provide a "default", unchangeable value for one of my constructors?

    In the absence of a convincing counterexample, the answer seems to be "no".

提交回复
热议问题