diff --git a/src/Agda2Hs/Compile/Name.hs b/src/Agda2Hs/Compile/Name.hs index 0e1f7cf0..42233e9b 100644 --- a/src/Agda2Hs/Compile/Name.hs +++ b/src/Agda2Hs/Compile/Name.hs @@ -8,7 +8,7 @@ import Control.Monad.Reader import Data.Functor ( (<&>) ) import Data.Bifunctor ( bimap ) -import Data.List ( intercalate, isPrefixOf ) +import Data.List ( intercalate, isPrefixOf, stripPrefix ) import Data.Text ( unpack ) import qualified Data.Map.Strict as Map @@ -115,6 +115,7 @@ compileQName f existsInHaskell <- orM [ pure $ isJust special , pure $ isPrimModule mod + , pure $ isHsModule mod , hasCompilePragma f , isClassFunction f , isWhereFunction f @@ -210,7 +211,12 @@ compileQName f in (mod', Just (Import mod' qual Nothing hf maybeIsType)) else (mod, Nothing) | otherwise - = (mod, Just (Import mod qual par hf maybeIsType)) + = let mod' = dropHaskellPrefix mod + in (mod', Just (Import mod' qual par hf maybeIsType)) + + dropHaskellPrefix :: Hs.ModuleName () -> Hs.ModuleName () + dropHaskellPrefix (Hs.ModuleName l s) = + Hs.ModuleName l $ fromMaybe s $ stripPrefix "Haskell." s isWhereFunction :: QName -> C Bool isWhereFunction f = do diff --git a/src/Agda2Hs/Compile/Utils.hs b/src/Agda2Hs/Compile/Utils.hs index 6d8ef53f..038c1bd8 100644 --- a/src/Agda2Hs/Compile/Utils.hs +++ b/src/Agda2Hs/Compile/Utils.hs @@ -64,6 +64,9 @@ primModules = isPrimModule :: Hs.ModuleName () -> Bool isPrimModule mod = any (`isPrefixOf` pp mod) primModules +isHsModule :: Hs.ModuleName () -> Bool +isHsModule mod = "Haskell." `isPrefixOf` pp mod + concatUnzip :: [([a], [b])] -> ([a], [b]) concatUnzip = (concat *** concat) . unzip