Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always drop "Haskell." prefix from module names #379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Agda2Hs/Compile/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -115,6 +115,7 @@ compileQName f
existsInHaskell <- orM
[ pure $ isJust special
, pure $ isPrimModule mod
, pure $ isHsModule mod
, hasCompilePragma f
, isClassFunction f
, isWhereFunction f
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/Agda2Hs/Compile/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading