Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Generalized newtype deriving errorForum ↗

Generalized newtype deriving error

App Development3 posts261 views1 likesLast activity Mar 2022
GY
gyorgybalazsiOP
Mar 2022

I need a generalized newtype declaration, and I’m trying to apply for this the appropriate language option, still get an error:

image

 Unexpected type ‘{getAge : Int}’
    In the newtype declaration for ‘Age’
    A newtype declaration should have form
      newtype Age a = ...parser

What am I missing?

RE
Remy
Mar 2022

I think you want to write

newtype Age = Age {getAge: Int} 
    deriving (Eq, Ord, Show, Enum)
GY
gyorgybalazsi
Mar 2022

Of course, thanks!

← Back to Discussions