@@ -87,9 +87,12 @@ compileType t = do
8787 reportSDoc " agda2hs.compile.type" 12 $ text " Compiling type" <+> prettyTCM t
8888 reportSDoc " agda2hs.compile.type" 22 $ text " Compiling type" <+> pretty t
8989
90+ toInline <- getInlineSymbols
91+ t <- locallyReduceDefs (OnlyReduceDefs toInline) $ reduce t
92+
9093 whenM (isErasedBaseType t) fail
9194
92- instantiate t >>= \ case
95+ case t of
9396 Pi a b -> do
9497 reportSDoc " agda2hs.compile.type" 13 $ text " Compiling pi type (" <+> prettyTCM (absName b)
9598 <+> text " :" <+> prettyTCM a <+> text " ) -> " <+> underAbstraction a b prettyTCM
@@ -110,10 +113,9 @@ compileType t = do
110113 | Just args <- allApplyElims es ->
111114 ifJustM (isUnboxRecord f) (\ _ -> compileUnboxType f args) $
112115 ifJustM (isTupleRecord f) (\ b -> compileTupleType f b args) $
113- ifM (isTransparentFunction f) (compileTransparentType (defType def) args) $
114- ifM (isInlinedFunction f) (compileInlineType f es) $ do
115- vs <- compileTypeArgs (defType def) args
116+ ifM (isTransparentFunction f) (compileTransparentType (defType def) args) $ do
116117 f <- compileQName f
118+ vs <- compileTypeArgs (defType def) args
117119 return $ tApp (Hs. TyCon () f) vs
118120 | otherwise -> fail
119121
@@ -151,10 +153,11 @@ compileType t = do
151153compileTypeArgs :: Type -> Args -> C [Hs. Type () ]
152154compileTypeArgs ty [] = pure []
153155compileTypeArgs ty (x: xs) = do
156+ reportSDoc " agda2hs.compile.type" 16 $ text " compileTypeArgs ty =" <+> prettyTCM x
154157 (a, b) <- mustBePi ty
155- reportSDoc " agda2hs.compile.type" 16 $ text " compileTypeArgs x =" <+> prettyTCM x
156- reportSDoc " agda2hs.compile.type" 16 $ text " a =" <+> prettyTCM a
157- reportSDoc " agda2hs.compile.type" 16 $ text " modality =" <+> prettyTCM (getModality a)
158+ reportSDoc " agda2hs.compile.type" 16 $ text " x =" <+> prettyTCM x
159+ reportSDoc " agda2hs.compile.type" 16 $ text " a =" <+> prettyTCM a
160+ reportSDoc " agda2hs.compile.type" 16 $ text " modality =" <+> prettyTCM (getModality a)
158161 let rest = compileTypeArgs (absApp b $ unArg x) xs
159162 let fail msg = agda2hsErrorM $ (text msg <> text " :" ) <+> parens (prettyTCM (absName b) <+> text " :" <+> prettyTCM (unDom a))
160163 compileDom a >>= \ case
@@ -204,23 +207,6 @@ compileTransparentType ty args = compileTypeArgs ty args >>= \case
204207 [] -> __IMPOSSIBLE__
205208
206209
207- compileInlineType :: QName -> Elims -> C (Hs. Type () )
208- compileInlineType f args = do
209- Function { funClauses = cs } <- theDef <$> getConstInfo f
210-
211- let [ Clause { namedClausePats = pats } ] = filter (isJust . clauseBody) cs
212-
213- when (length args < length pats) $ agda2hsErrorM $
214- text " Cannot compile inlinable type alias" <+> prettyTCM f <+> text " as it must be fully applied."
215-
216- r <- liftReduce $ locallyReduceDefs (OnlyReduceDefs $ Set. singleton f)
217- $ unfoldDefinitionStep (Def f args) f args
218-
219- case r of
220- YesReduction _ t -> compileType t
221- _ -> agda2hsErrorM $ text " Could not reduce inline type alias " <+> prettyTCM f
222-
223-
224210data DomOutput = DOInstance | DODropped | DOType | DOTerm
225211
226212compileDom :: Dom Type -> C DomOutput
0 commit comments