@@ -668,17 +668,22 @@ elabInstance :: ElabInfo -> SyntaxInfo ->
668 Name -> -- the class
668 Name -> -- the class
669 [PTerm] -> -- class parameters (i.e. instance)
669 [PTerm] -> -- class parameters (i.e. instance)
670 PTerm -> -- full instance type
670 PTerm -> -- full instance type
671+ Maybe Name -> -- explicit name
671 [PDecl] -> Idris ()
672 [PDecl] -> Idris ()
672−elabInstance info syn fc cs n ps t ds
673+elabInstance info syn fc cs n ps t expn ds
673 = do i <- get
674 = do i <- get
674 (n, ci) <- case lookupCtxtName (namespace info) n (idris_classes i) of
675 (n, ci) <- case lookupCtxtName (namespace info) n (idris_classes i) of
675 [c] -> return c
676 [c] -> return c
676 _ -> fail $ show fc ++ ":" ++ show n ++ " is not a type class"
677 _ -> fail $ show fc ++ ":" ++ show n ++ " is not a type class"
678+ let iname = case expn of
677− let iname = UN ('@':show n ++ "$" ++ show ps)
679+ Nothing -> UN ('@':show n ++ "$" ++ show ps)
678 -- if the instance type matches any of the instances we have already,
681 -- if the instance type matches any of the instances we have already,
679− -- then it's overlapping, so report an error
682+ -- and it's not a named instance, then it's overlapping, so report an error
680− mapM_ (checkNotOverlapping i t) (class_instances ci)
684+ Nothing -> do mapM_ (checkNotOverlapping i t) (class_instances ci)
685+ addInstance intInst n iname
681− addInstance intInst n iname
686+ Just _ -> addInstance intInst n iname
682 elabType info syn fc [] iname t
687 elabType info syn fc [] iname t
683 let ips = zip (class_params ci) ps
688 let ips = zip (class_params ci) ps
684 let ns = case n of
689 let ns = case n of
@@ -858,9 +863,9 @@ elabDecl' info (PNamespace n ps) = mapM_ (elabDecl' ninfo) ps
858 Just ns -> info { namespace = Just (n:ns) }
863 Just ns -> info { namespace = Just (n:ns) }
859elabDecl' info (PClass s f cs n ps ds) = do iLOG $ "Elaborating class " ++ show n
864elabDecl' info (PClass s f cs n ps ds) = do iLOG $ "Elaborating class " ++ show n
860 elabClass info s f cs n ps ds
865 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)
862 = do iLOG $ "Elaborating instance " ++ show n
867 = 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
864elabDecl' info (PRecord s f tyn ty cn cty)
869elabDecl' info (PRecord s f tyn ty cn cty)
865 = do iLOG $ "Elaborating record " ++ show tyn
870 = do iLOG $ "Elaborating record " ++ show tyn
866 elabRecord info s f tyn ty cn cty
871 elabRecord info s f tyn ty cn cty