@@ -663,12 +663,25 @@ process h fn (Eval t)
663663 tyDoc = pprintDelab ist ty'
664664 ihPrintTermWithType h tmDoc tyDoc
665665
666−process h fn (NewDefn name val)
667− = do (tm, ty) <- elabVal toplevel False val
668− ctxt <- getContext
669− let tm' = force (normaliseAll ctxt [] tm)
670− let ty' = force (normaliseAll ctxt [] ty)
671− updateContext (addCtxtDef name (Function ty' tm'))
666+process h fn (NewDefn fc (tyDecl:decls))
667+ | isTyDecl tyDecl = do
668+ elabDecl EAll toplevel tyDecl
669+ name <- getName tyDecl
670+ logLvl 3 $ "Defining " ++ show name ++ " with this type decl: " ++ show tyDecl
671+ logLvl 5 $ "Using this definition: " ++ show decls
672+ elabClauses toplevel fc [] name defn
673+ where getName (PTy docs argdocs syn fc opts name ty) = return name
674+ getName _ = fail "New definitions must begin with a type declaration"
675+ isTyDecl PTy{} = True
676+ isTyDecl _ = False
677+ defn = concatMap getClauses decls
678+ getClauses (PClauses fc opts name clauses) = clauses
679+ getClauses _ = []
680+ -- = do (tm, ty) <- elabVal toplevel False val
681+ -- ctxt <- getContext
682+ -- let tm' = force (normaliseAll ctxt [] tm)
683+ -- let ty' = force (normaliseAll ctxt [] ty)
684+ -- updateContext (addCtxtDef name (Function ty' tm'))
672685
673686process h fn (ExecVal t)
674687 = do ctxt <- getContext