1
- {-# LANGUAGE NamedFieldPuns, ImportQualifiedPost #-}
1
+ {-# LANGUAGE NamedFieldPuns, ImportQualifiedPost, DataKinds #-}
2
2
-- | Convert Agda datatypes to λ□ inductive declarations
3
3
module Agda2Lambox.Compile.Inductive
4
4
( compileInductive
@@ -14,7 +14,7 @@ import Data.Maybe ( isJust, listToMaybe, fromMaybe )
14
14
import Data.Traversable ( mapM )
15
15
16
16
import Agda.Syntax.Abstract.Name ( qnameModule , qnameName )
17
- import Agda.TypeChecking.Monad.Base
17
+ import Agda.TypeChecking.Monad.Base hiding ( None )
18
18
import Agda.TypeChecking.Monad.Env ( withCurrentModule )
19
19
import Agda.TypeChecking.Datatypes ( ConstructorInfo (.. ), getConstructorInfo , isDatatype )
20
20
import Agda.Compiler.Backend ( getConstInfo , lookupMutualBlock )
@@ -23,13 +23,14 @@ import Agda.Syntax.Internal ( ConHead(..), unDom )
23
23
import Agda.Utils.Monad ( unlessM )
24
24
25
25
import Agda.Utils ( isDataOrRecDef )
26
+ import Agda2Lambox.Compile.Target
26
27
import Agda2Lambox.Compile.Utils
27
28
import Agda2Lambox.Compile.Monad
28
29
import LambdaBox qualified as LBox
29
30
30
31
31
32
-- | Toplevel conversion from a datatype/record definition to a Lambdabox declaration.
32
- compileInductive :: Definition -> CompileM (Maybe LBox. GlobalDecl )
33
+ compileInductive :: Definition -> CompileM (Maybe ( LBox. GlobalDecl Untyped ) )
33
34
compileInductive defn@ Defn {defName} = do
34
35
mutuals <- liftTCM $ dataOrRecDefMutuals defn
35
36
@@ -69,16 +70,17 @@ compileInductive defn@Defn{defName} = do
69
70
, indBodies = NEL. toList bodies
70
71
}
71
72
72
- actuallyConvertInductive :: Definition -> TCM LBox. OneInductiveBody
73
+ actuallyConvertInductive :: Definition -> TCM ( LBox. OneInductiveBody Untyped )
73
74
actuallyConvertInductive Defn {defName, theDef, defMutual} = case theDef of
74
75
Datatype {.. } -> do
75
76
76
- ctors :: [LBox. ConstructorBody ]
77
+ ctors :: [LBox. ConstructorBody Untyped ]
77
78
<- forM dataCons \ cname -> do
78
79
DataCon arity <- getConstructorInfo cname
79
- return LBox. Ctor
80
- { ctorName = prettyShow $ qnameName cname
81
- , ctorArgs = arity
80
+ return LBox. Constructor
81
+ { cstrName = prettyShow $ qnameName cname
82
+ , cstrArgs = arity
83
+ , cstrTypes = None
82
84
}
83
85
84
86
pure LBox. OneInductive
@@ -87,19 +89,23 @@ actuallyConvertInductive Defn{defName, theDef, defMutual} = case theDef of
87
89
, indKElim = LBox. IntoAny -- TODO(flupe)
88
90
, indCtors = ctors
89
91
, indProjs = []
92
+ , indTypeVars = None
90
93
}
91
94
92
95
Record {.. } -> do
93
96
94
97
let ConHead {conName, conFields} = recConHead
95
- fields :: [LBox. ProjectionBody ] = LBox. Proj . prettyShow . qnameName . unDom <$> recFields
98
+ fields :: [LBox. ProjectionBody Untyped ] =
99
+ flip LBox. Projection None . prettyShow . qnameName . unDom <$> recFields
96
100
97
101
pure LBox. OneInductive
98
102
{ indName = prettyShow $ qnameName defName
99
103
, indPropositional = False -- TODO(flupe)
100
104
, indKElim = LBox. IntoAny -- TODO(flupe)
101
- , indCtors = [ LBox. Ctor (prettyShow $ qnameName conName) (length conFields) ]
105
+ , indCtors =
106
+ [ LBox. Constructor (prettyShow $ qnameName conName) (length conFields) None ]
102
107
, indProjs = fields
108
+ , indTypeVars = None
103
109
}
104
110
105
111
-- { indFinite = maybe LBox.BiFinite inductionToRecKind recInduction
0 commit comments