@@ -626,8 +626,8 @@ elabPrims = do mapM_ (elabDecl EAll toplevel)
628-- | Elaborate a type provider
628-- | Elaborate a type provider
629−elabProvider :: ElabInfo -> SyntaxInfo -> FC -> Name -> PTerm -> PTerm -> Idris ()
629+elabProvider :: ElabInfo -> SyntaxInfo -> FC -> ProvideWhat -> Name -> PTerm -> PTerm -> Idris ()
630−elabProvider info syn fc n ty tm
630+elabProvider info syn fc what n ty tm
631 = do i <- getIState
631 = do i <- getIState
632 -- Ensure that the experimental extension is enabled
632 -- Ensure that the experimental extension is enabled
633 unless (TypeProviders `elem` idris_language_extensions i) $
633 unless (TypeProviders `elem` idris_language_extensions i) $
@@ -647,9 +647,6 @@ elabProvider info syn fc n ty tm
647 ifail $ "Expected provider type IO (Provider (" ++
647 ifail $ "Expected provider type IO (Provider (" ++
648 show ty' ++ "))" ++ ", got " ++ show et ++ " instead."
648 show ty' ++ "))" ++ ", got " ++ show et ++ " instead."
650− -- Create the top-level type declaration
651− elabType info syn "" fc [] n ty
653 -- Execute the type provider and normalise the result
650 -- Execute the type provider and normalise the result
654 -- use 'run__provider' to convert to a primitive IO action
651 -- use 'run__provider' to convert to a primitive IO action
@@ -658,12 +655,25 @@ elabProvider info syn fc n ty tm
658 let rhs' = normalise ctxt [] rhs
655 let rhs' = normalise ctxt [] rhs
659 logLvl 1 $ "Normalised " ++ show n ++ "'s RHS to " ++ show rhs
656 logLvl 1 $ "Normalised " ++ show n ++ "'s RHS to " ++ show rhs
661− -- Extract the provided term from the type provider
658+ -- Extract the provided term or postulate from the type provider
662− tm <- getProvided fc rhs'
659+ provided <- getProvided fc rhs'
663+ | what `elem` [ProvTerm, ProvAny] ->
664− -- Finally add a top-level definition of the provided term
664+ do -- Finally add a top-level definition of the provided term
665+ elabType info syn "" fc [] n ty
665− elabClauses info fc [] n [PClause fc n (PApp fc (PRef fc n) []) [] (delab i tm) []]
666+ elabClauses info fc [] n [PClause fc n (PApp fc (PRef fc n) []) [] (delab i tm) []]
666− logLvl 1 $ "Elaborated provider " ++ show n ++ " as: " ++ show tm
667+ logLvl 1 $ "Elaborated provider " ++ show n ++ " as: " ++ show tm
669+ ierror . Msg $ "Attempted to provide a term where a postulate was expected."
671+ | what `elem` [ProvPostulate, ProvAny] ->
672+ do -- Add the postulate
673+ elabPostulate info syn "Provided postulate" fc [] n ty
674+ logLvl 1 $ "Elaborated provided postulate " ++ show n
676+ ierror . Msg $ "Attempted to provide a postulate where a term was expected."
668 where isTType :: TT Name -> Bool
678 where isTType :: TT Name -> Bool
669 isTType (TType _) = True
679 isTType (TType _) = True
@@ -2224,10 +2234,10 @@ elabDecl' _ info (PDSL n dsl)
2224 addIBC (IBCDSL n)
2234 addIBC (IBCDSL n)
2225elabDecl' what info (PDirective i)
2235elabDecl' what info (PDirective i)
2226 | what /= EDefns = i
2236 | what /= EDefns = i
2227−elabDecl' what info (PProvider syn fc n tp tm)
2237+elabDecl' what info (PProvider syn fc provWhat n tp tm)
2228 | what /= EDefns
2238 | what /= EDefns
2229 = do iLOG $ "Elaborating type provider " ++ show n
2239 = do iLOG $ "Elaborating type provider " ++ show n
2230− elabProvider info syn fc n tp tm
2240+ elabProvider info syn fc provWhat n tp tm
2231elabDecl' what info (PTransform fc safety old new)
2241elabDecl' what info (PTransform fc safety old new)
2232 = elabTransform info fc safety old new
2242 = elabTransform info fc safety old new
2233elabDecl' _ _ _ = return () -- skipped this time
2243elabDecl' _ _ _ = return () -- skipped this time