Skip to content

Commit b69790e

Browse files
committed
[ fix #391 ] Add imports for Haskell.* modules (other than Prelude)
1 parent 0d622cf commit b69790e

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

Diff for: src/Agda2Hs/Compile.hs

+6-8
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ verifyOutput ::
120120
verifyOutput _ _ _ m ls = do
121121
reportSDoc "agda2hs.compile" 5 $ text "Checking generated output before rendering: " <+> prettyTCM m
122122
ensureUniqueConstructors
123-
ensureNoOutputFromPrimModules
123+
ensureNoOutputFromHsModules
124124
where
125125
ensureUniqueConstructors = do
126126
let allCons = do
@@ -136,17 +136,15 @@ verifyOutput _ _ _ m ls = do
136136
when (length duplicateCons > 0) $
137137
genericDocError =<< vcat (map (\x -> text $ "Cannot generate multiple constructors with the same identifier: " <> Hs.prettyPrint (headWithDefault __IMPOSSIBLE__ x)) duplicateCons)
138138

139-
ensureNoOutputFromPrimModules = unless (null $ concat $ map fst ls) $ do
139+
ensureNoOutputFromHsModules = unless (null $ concat $ map fst ls) $ do
140140
let hsModName = hsTopLevelModuleName m
141-
when (isPrimModule hsModName) $ do
142-
reportSDoc "agda2hs.compile" 10 $ text "Primitive module" <+> prettyTCM m <+> text "has non-null output."
143-
if isHsModule hsModName
144-
then genericDocError =<< hsep
141+
when (isHsModule hsModName) $ do
142+
reportSDoc "agda2hs.compile" 10 $ text "Haskell module" <+> prettyTCM m <+> text "has non-null output."
143+
genericDocError =<< hsep
145144
( pwords "The `Haskell.` namespace are reserved for binding existing Haskell modules, so the module"
146145
++ [text "`" <> prettyTCM m <> text "`"]
147146
++ pwords "should not contain any"
148147
++ [text "`{-# COMPILE AGDA2HS ... #-}`"]
149148
++ pwords "pragmas that produce Haskell code."
150149
)
151-
else do
152-
__IMPOSSIBLE_VERBOSE__ "Primitive Agda module should not have any COMPILE AGDA2HS pragmas!"
150+
when (isPrimModule hsModName) __IMPOSSIBLE__

Diff for: src/Agda2Hs/Compile/Name.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ toNameImport x (Just mod) =
6666
defaultSpecialRules :: SpecialRules
6767
defaultSpecialRules = Map.fromList
6868
[ "Agda.Builtin.Nat.Nat" `to` "Natural" `importing` Just "Numeric.Natural"
69-
, "Haskell.Control.Monad.guard" `to` "guard" `importing` Just "Control.Monad"
70-
, "Haskell.Control.Exception.assert" `to` "assert" `importing` Just "Control.Exception"
7169
, "Haskell.Prelude.coerce" `to` "unsafeCoerce" `importing` Just "Unsafe.Coerce"
7270
, "Agda.Builtin.Int.Int" `to` "Integer" `importing` Nothing
7371
, "Agda.Builtin.Word.Word64" `to` "Word" `importing` Nothing
@@ -116,6 +114,7 @@ compileQName f
116114
existsInHaskell <- orM
117115
[ pure $ isJust special
118116
, pure $ isPrimModule mod
117+
, pure $ isHsModule mod
119118
, hasCompilePragma f
120119
, isClassFunction f
121120
, isWhereFunction f

Diff for: src/Agda2Hs/Compile/Utils.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import Agda.Utils.Impossible ( __IMPOSSIBLE__ )
5757
primModules =
5858
[ "Agda.Builtin"
5959
, "Agda.Primitive"
60-
, "Haskell"
60+
, "Haskell.Prim"
61+
, "Haskell.Prelude"
6162
]
6263

6364
isPrimModule :: Hs.ModuleName () -> Bool

0 commit comments

Comments
 (0)