@@ -681,8 +681,8 @@ elabPrims = do mapM_ (elabDecl EAll toplevel)
683-- | Elaborate a type provider
683-- | Elaborate a type provider
684−elabProvider :: ElabInfo -> SyntaxInfo -> FC -> ProvideWhat -> Name -> PTerm -> PTerm -> Idris ()
684+elabProvider :: ElabInfo -> SyntaxInfo -> FC -> ProvideWhat -> Name -> Idris ()
685−elabProvider info syn fc what n ty tm
685+elabProvider info syn fc what n
686 = do i <- getIState
686 = do i <- getIState
687 -- Ensure that the experimental extension is enabled
687 -- Ensure that the experimental extension is enabled
688 unless (TypeProviders `elem` idris_language_extensions i) $
688 unless (TypeProviders `elem` idris_language_extensions i) $
@@ -692,12 +692,17 @@ elabProvider info syn fc what n ty tm
692 ctxt <- getContext
692 ctxt <- getContext
694 -- First elaborate the expected type (and check that it's a type)
694 -- First elaborate the expected type (and check that it's a type)
695+ -- The goal type for a postulate is always Type.
696+ (ty', typ) <- case what of
695− (ty', typ) <- elabVal toplevel False ty
697+ ProvTerm ty p -> elabVal toplevel False ty
698+ ProvPostulate _ -> elabVal toplevel False PType
696 unless (isTType typ) $
699 unless (isTType typ) $
697 ifail ("Expected a type, got " ++ show ty' ++ " : " ++ show typ)
700 ifail ("Expected a type, got " ++ show ty' ++ " : " ++ show typ)
699 -- Elaborate the provider term to TT and check that the type matches
702 -- Elaborate the provider term to TT and check that the type matches
703+ (e, et) <- case what of
704+ ProvTerm _ tm -> elabVal toplevel False tm
700− (e, et) <- elabVal toplevel False tm
705+ ProvPostulate tm -> elabVal toplevel False tm
701 unless (isProviderOf (normalise ctxt [] ty') et) $
706 unless (isProviderOf (normalise ctxt [] ty') et) $
702 ifail $ "Expected provider type IO (Provider (" ++
707 ifail $ "Expected provider type IO (Provider (" ++
703 show ty' ++ "))" ++ ", got " ++ show et ++ " instead."
708 show ty' ++ "))" ++ ", got " ++ show et ++ " instead."
@@ -715,17 +720,14 @@ elabProvider info syn fc what n ty tm
716 case provided of
721 case provided of
717 Provide tm
722 Provide tm
718− | what `elem` [ProvTerm, ProvAny] ->
723+ | ProvTerm ty _ <- what ->
719 do -- Finally add a top-level definition of the provided term
724 do -- Finally add a top-level definition of the provided term
720 elabType info syn emptyDocstring [] fc [] n ty
725 elabType info syn emptyDocstring [] fc [] n ty
721 elabClauses info fc [] n [PClause fc n (PApp fc (PRef fc n) []) [] (delab i tm) []]
726 elabClauses info fc [] n [PClause fc n (PApp fc (PRef fc n) []) [] (delab i tm) []]
722 logLvl 3 $ "Elaborated provider " ++ show n ++ " as: " ++ show tm
727 logLvl 3 $ "Elaborated provider " ++ show n ++ " as: " ++ show tm
724− ierror . Msg $ "Attempted to provide a term where a postulate was expected."
726− | what `elem` [ProvPostulate, ProvAny] ->
728+ | ProvPostulate _ <- what ->
727 do -- Add the postulate
729 do -- Add the postulate
728− elabPostulate info syn (parseDocstring $ T.pack "Provided postulate") fc [] n ty
730+ elabPostulate info syn (parseDocstring $ T.pack "Provided postulate") fc [] n (delab i tm)
729 logLvl 3 $ "Elaborated provided postulate " ++ show n
731 logLvl 3 $ "Elaborated provided postulate " ++ show n
730 | otherwise ->
732 | otherwise ->
731 ierror . Msg $ "Attempted to provide a postulate where a term was expected."
733 ierror . Msg $ "Attempted to provide a postulate where a term was expected."
@@ -2408,10 +2410,10 @@ elabDecl' _ info (PDSL n dsl)
2408 addIBC (IBCDSL n)
2410 addIBC (IBCDSL n)
2409elabDecl' what info (PDirective i)
2411elabDecl' what info (PDirective i)
2410 | what /= EDefns = i
2412 | what /= EDefns = i
2411−elabDecl' what info (PProvider syn fc provWhat n tp tm)
2413+elabDecl' what info (PProvider syn fc provWhat n)
2412 | what /= EDefns
2414 | what /= EDefns
2413 = do iLOG $ "Elaborating type provider " ++ show n
2415 = do iLOG $ "Elaborating type provider " ++ show n
2414− elabProvider info syn fc provWhat n tp tm
2416+ elabProvider info syn fc provWhat n
2415elabDecl' what info (PTransform fc safety old new)
2417elabDecl' what info (PTransform fc safety old new)
2416 = elabTransform info fc safety old new
2418 = elabTransform info fc safety old new
2417elabDecl' _ _ _ = return () -- skipped this time
2419elabDecl' _ _ _ = return () -- skipped this time