@@ -77,6 +77,7 @@ data SimpleErrorMessage
7777 | NoInstanceFound Constraint
7878 | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [Type ]
7979 | CannotDerive (Qualified (ProperName 'ClassName)) [Type ]
80+ | InvalidNewtypeInstance (Qualified (ProperName 'ClassName)) [Type ]
8081 | CannotFindDerivingType (ProperName 'TypeName)
8182 | DuplicateLabel String (Maybe Expr )
8283 | DuplicateValueDeclaration Ident
@@ -374,19 +375,24 @@ pattern TypeFixityDeclaration fixity name op = FixityDeclaration (Right (TypeFix
374375
375376-- | The members of a type class instance declaration
376377data TypeInstanceBody
377- -- | This is a derived instance
378378 = DerivedInstance
379- -- | This is a regular (explicit) instance
379+ -- ^ This is a derived instance
380+ | NewtypeInstance
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.
380385 | ExplicitInstance [Declaration ]
386+ -- ^ This is a regular (explicit) instance
381387 deriving (Show )
382388
383389mapTypeInstanceBody :: ([Declaration ] -> [Declaration ]) -> TypeInstanceBody -> TypeInstanceBody
384390mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
385391
386392-- | A traversal for TypeInstanceBody
387393traverseTypeInstanceBody :: (Applicative f ) => ([Declaration ] -> f [Declaration ]) -> TypeInstanceBody -> f TypeInstanceBody
388- traverseTypeInstanceBody _ DerivedInstance = pure DerivedInstance
389394traverseTypeInstanceBody f (ExplicitInstance ds) = ExplicitInstance <$> f ds
395+ traverseTypeInstanceBody _ other = pure other
390396
391397-- |
392398-- Test if a declaration is a value declaration
@@ -570,7 +576,7 @@ data Expr
570576 -- |
571577 -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
572578 --
573- | SuperClassDictionary (Qualified (ProperName 'ClassName)) [Type ]
579+ | DeferredDictionary (Qualified (ProperName 'ClassName)) [Type ]
574580 -- |
575581 -- A placeholder for an anonymous function argument
576582 --
0 commit comments