@@ -668,17 +668,22 @@ elabInstance :: ElabInfo -> SyntaxInfo ->
668668 Name -> -- the class
669669 [PTerm] -> -- class parameters (i.e. instance)
670670 PTerm -> -- full instance type
671+ Maybe Name -> -- explicit name
671672 [PDecl] -> Idris ()
672−elabInstance info syn fc cs n ps t ds
673+elabInstance info syn fc cs n ps t expn ds
673674 = do i <- get
674675 (n, ci) <- case lookupCtxtName (namespace info) n (idris_classes i) of
675676 [c] -> return c
676677 _ -> fail $ show fc ++ ":" ++ show n ++ " is not a type class"
677− let iname = UN ('@':show n ++ "$" ++ show ps)
678+ let iname = case expn of
679+ Nothing -> UN ('@':show n ++ "$" ++ show ps)
680+ Just nm -> nm
678681 -- if the instance type matches any of the instances we have already,
679− -- then it's overlapping, so report an error
680− mapM_ (checkNotOverlapping i t) (class_instances ci)
681− addInstance intInst n iname
682+ -- and it's not a named instance, then it's overlapping, so report an error
683+ case expn of
684+ Nothing -> do mapM_ (checkNotOverlapping i t) (class_instances ci)
685+ addInstance intInst n iname
686+ Just _ -> addInstance intInst n iname
682687 elabType info syn fc [] iname t
683688 let ips = zip (class_params ci) ps
684689 let ns = case n of
@@ -858,9 +863,9 @@ elabDecl' info (PNamespace n ps) = mapM_ (elabDecl' ninfo) ps
858863 Just ns -> info { namespace = Just (n:ns) }
859864elabDecl' info (PClass s f cs n ps ds) = do iLOG $ "Elaborating class " ++ show n
860865 elabClass info s f cs n ps ds
861−elabDecl' info (PInstance s f cs n ps t ds)
866+elabDecl' info (PInstance s f cs n ps t expn ds)
862867 = do iLOG $ "Elaborating instance " ++ show n
863− elabInstance info s f cs n ps t ds
868+ elabInstance info s f cs n ps t expn ds
864869elabDecl' info (PRecord s f tyn ty cn cty)
865870 = do iLOG $ "Elaborating record " ++ show tyn
866871 elabRecord info s f tyn ty cn cty