@@ -12,16 +12,17 @@ import Agda.Syntax.Common (Arg(..))
1212import Agda.Syntax.Common.Pretty ( prettyShow )
1313import Agda.TypeChecking.Monad ( liftTCM , getConstInfo )
1414import Agda.TypeChecking.Pretty
15- import Agda.Utils.Monad ( whenM , ifM )
15+ import Agda.Utils.Monad ( whenM , ifM , unlessM , ifNotM , orM )
1616
17- import Agda.Utils ( hasPragma , isDataOrRecDef , treeless )
17+ import Agda.Utils ( hasPragma , isDataOrRecDef , treeless , isArity )
1818
1919import Agda2Lambox.Compile.Monad
2020import Agda2Lambox.Compile.Target
2121import Agda2Lambox.Compile.Utils
22- import Agda2Lambox.Compile.Term ( compileTerm )
23- import Agda2Lambox.Compile.Function ( compileFunction )
24- import Agda2Lambox.Compile.Inductive ( compileInductive )
22+ import Agda2Lambox.Compile.Term ( compileTerm )
23+ import Agda2Lambox.Compile.Function ( compileFunction )
24+ import Agda2Lambox.Compile.Inductive ( compileInductive )
25+ import Agda2Lambox.Compile.TypeScheme ( compileTypeScheme )
2526
2627import LambdaBox.Names
2728import LambdaBox.Env (GlobalEnv (.. ), GlobalDecl (.. ), ConstantBody (.. ))
@@ -37,8 +38,12 @@ compileDefinition :: Target t -> Definition -> CompileM (Maybe (KerName, GlobalD
3738compileDefinition target defn@ Defn {.. } = setCurrentRange defName do
3839 reportSDoc " agda2lambox.compile" 1 $ " Compiling definition: " <+> prettyTCM defName
3940
40- -- we skip logical definitions altogether
41- ifM (liftTCM $ isLogical $ Arg defArgInfo defType) (pure Nothing ) do
41+ -- we skip logical definitions altogether,
42+ -- and definitions introduced by module application
43+ ifM
44+ (orM [ pure defCopy
45+ , liftTCM $ isLogical $ Arg defArgInfo defType])
46+ (pure Nothing ) do
4247
4348 -- prepend kername
4449 fmap (qnameToKerName defName,) <$> case theDef of
@@ -50,7 +55,13 @@ compileDefinition target defn@Defn{..} = setCurrentRange defName do
5055
5156 Constructor {conData} -> Nothing <$ requireDef conData
5257
53- Function {} -> compileFunction target defn
58+ Function {} -> do
59+ ifNotM (liftTCM $ isArity defType) (compileFunction target defn) do
60+ -- it's a type scheme
61+ case target of
62+ ToUntyped -> pure Nothing
63+ -- we only compile it with --typed
64+ ToTyped -> Just <$> compileTypeScheme defn
5465
5566 d | isDataOrRecDef d -> compileInductive target defn
5667
0 commit comments