summaryrefslogtreecommitdiff
path: root/Biz/Namespace.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Namespace.hs')
-rw-r--r--Biz/Namespace.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Biz/Namespace.hs b/Biz/Namespace.hs
index 72e3fa1..f0e3b32 100644
--- a/Biz/Namespace.hs
+++ b/Biz/Namespace.hs
@@ -9,6 +9,7 @@ module Biz.Namespace
Ext (..),
fromPath,
toPath,
+ toModule,
fromHaskellContent,
fromHaskellModule,
toHaskellModule,
@@ -85,18 +86,19 @@ fromHaskellContent c = case Regex.findFirstInfix haskellModule c of
</ (Regex.string "\nmodule " *> Regex.many (name <|> dot))
<*> pure Hs
+toModule (Namespace parts Hs) = joinWith "." parts
+toModule (Namespace parts Py) = joinWith "." parts
+toModule (Namespace parts Scm) = "(" ++ joinWith " " parts ++ ")"
+toModule (Namespace {..}) = panic <| "toModule not implemented for " <> show ext
+
toHaskellModule :: Namespace -> String
-toHaskellModule (Namespace parts Hs) = joinWith "." parts
-toHaskellModule (Namespace {..}) =
- panic <| "can't convert " <> show ext <> " to a Haskell module"
+toHaskellModule = toModule
fromHaskellModule :: String -> Namespace
fromHaskellModule s = Namespace (List.splitOn "." s) Hs
toSchemeModule :: Namespace -> String
-toSchemeModule (Namespace parts Scm) = "(" ++ joinWith " " parts ++ ")"
-toSchemeModule (Namespace {..}) =
- panic <| "can't convert " <> show ext <> " to a Scheme module"
+toSchemeModule = toModule
dot :: Regex.RE Char String
dot = Regex.some <| Regex.sym '.'