@@ -77,6 +77,7 @@ data SimpleErrorMessage
77 | NoInstanceFound Constraint
77 | NoInstanceFound Constraint
78 | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [Type]
78 | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [Type]
79 | CannotDerive (Qualified (ProperName 'ClassName)) [Type]
79 | CannotDerive (Qualified (ProperName 'ClassName)) [Type]
80+ | InvalidNewtypeInstance (Qualified (ProperName 'ClassName)) [Type]
80 | CannotFindDerivingType (ProperName 'TypeName)
81 | CannotFindDerivingType (ProperName 'TypeName)
81 | DuplicateLabel String (Maybe Expr)
82 | DuplicateLabel String (Maybe Expr)
82 | DuplicateValueDeclaration Ident
83 | DuplicateValueDeclaration Ident
@@ -374,10 +375,15 @@ pattern TypeFixityDeclaration fixity name op = FixityDeclaration (Right (TypeFix
375-- | The members of a type class instance declaration
376-- | The members of a type class instance declaration
376data TypeInstanceBody
377data TypeInstanceBody
377− -- | This is a derived instance
378 = DerivedInstance
378 = DerivedInstance
379− -- | This is a regular (explicit) instance
379+ -- ^ This is a derived instance
381+ -- ^ This is an instance derived from a newtype
382+ | NewtypeInstanceWithDictionary Expr
383+ -- ^ This is an instance derived from a newtype, desugared to include a
384+ -- dictionary for the type under the newtype.
380 | ExplicitInstance [Declaration]
385 | ExplicitInstance [Declaration]
386+ -- ^ This is a regular (explicit) instance
381 deriving (Show)
387 deriving (Show)
383mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
389mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
@@ -385,8 +391,8 @@ mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
386-- | A traversal for TypeInstanceBody
392-- | A traversal for TypeInstanceBody
387traverseTypeInstanceBody :: (Applicative f) => ([Declaration] -> f [Declaration]) -> TypeInstanceBody -> f TypeInstanceBody
393traverseTypeInstanceBody :: (Applicative f) => ([Declaration] -> f [Declaration]) -> TypeInstanceBody -> f TypeInstanceBody
388−traverseTypeInstanceBody _ DerivedInstance = pure DerivedInstance
389traverseTypeInstanceBody f (ExplicitInstance ds) = ExplicitInstance <$> f ds
394traverseTypeInstanceBody f (ExplicitInstance ds) = ExplicitInstance <$> f ds
395+traverseTypeInstanceBody _ other = pure other
392-- Test if a declaration is a value declaration
398-- Test if a declaration is a value declaration
@@ -570,7 +576,7 @@ data Expr
571 -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
577 -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
573− | SuperClassDictionary (Qualified (ProperName 'ClassName)) [Type]
579+ | DeferredDictionary (Qualified (ProperName 'ClassName)) [Type]
575 -- A placeholder for an anonymous function argument
581 -- A placeholder for an anonymous function argument