@@ -54,7 +54,7 @@ elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
5454 = do let codata = Codata `elem` opts
5555 iLOG (show (fc, doc))
5656 checkUndefined fc n
57− (cty, t, inacc) <- buildType info syn fc [] n t_in
57+ (cty, _, t, inacc) <- buildType info syn fc [] n t_in
5858
5959 addIBC (IBCDef n)
6060 updateContext (addTyDecl n (TCon 0 0) cty) -- temporary, to check cons
@@ -63,7 +63,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
6363 = do let codata = Codata `elem` opts
6464 iLOG (show fc)
6565 undef <- isUndefined fc n
66− (cty, t, inacc) <- buildType info syn fc [] n t_in
66+ (cty, _, t, inacc) <- buildType info syn fc [] n t_in
6767 -- if n is defined already, make sure it is just a type declaration
6868 -- with the same type we've just elaborated
6969 i <- getIState
@@ -71,7 +71,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
7171 -- temporary, to check cons
7272 when undef $ updateContext (addTyDecl n (TCon 0 0) cty)
7373 let cnameinfo = cinfo info (map cname dcons)
74− cons <- mapM (elabCon cnameinfo syn n codata) dcons
74+ cons <- mapM (elabCon cnameinfo syn n codata (getRetTy cty)) dcons
7575 ttag <- getName
7676 i <- getIState
7777 let as = map (const Nothing) (getArgTys cty)
@@ -203,12 +203,15 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
203203-- TODO: the above is a comment from the past;
204204-- forcenames is probably no longer needed
205205elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool ->
206− (Docstring, [(Name, Docstring)], Name, PTerm, FC, [Name]) -> Idris (Name, Type)
207−elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
206+ Type -> -- for kind checking
207+ (Docstring, [(Name, Docstring)], Name, PTerm, FC, [Name]) ->
208+ Idris (Name, Type)
209+elabCon info syn tn codata expkind (doc, argDocs, n, t_in, fc, forcenames)
208210 = do checkUndefined fc n
209− (cty, t, inacc) <- buildType info syn fc [Constructor] n (if codata then mkLazy t_in else t_in)
211+ (cty, ckind, t, inacc) <- buildType info syn fc [Constructor] n (if codata then mkLazy t_in else t_in)
210212 ctxt <- getContext
211213 let cty' = normalise ctxt [] cty
214+ checkUniqueKind ckind expkind
212215
213216 -- Check that the constructor type is, in fact, a part of the family being defined
214217 tyIs n cty'
@@ -250,6 +253,15 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
250253 | otherwise = getNamePos (i + 1) sc x
251254 getNamePos _ _ _ = Nothing
252255
256+ -- if the constructor is a UniqueType, the datatype must be too
257+ -- (Type* is fine, since that is checked for uniqueness too)
258+ checkUniqueKind (UType UniqueType) (UType UniqueType) = return ()
259+ checkUniqueKind (UType UniqueType) (UType AllTypes) = return ()
260+ checkUniqueKind (UType UniqueType) (TType _)
261+ = tclift $ tfail (UniqueKindError n)
262+ checkUniqueKind (UType AllTypes) _ = return ()
263+ checkUniqueKind (TType _) _ = return ()
264+
253265type EliminatorState = StateT (Map.Map String Int) Idris
254266
255267-- TODO: Rewrite everything to use idris_implicits instead of manual splitting (or in TT)