diff options
Diffstat (limited to 'Biz/Namespace.hs')
-rw-r--r-- | Biz/Namespace.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Biz/Namespace.hs b/Biz/Namespace.hs index 48f6277..bd283a6 100644 --- a/Biz/Namespace.hs +++ b/Biz/Namespace.hs @@ -31,9 +31,11 @@ import qualified Data.Text as Text import qualified Text.Regex.Applicative as Regex data Ext - = C + = Bash + | C | Css | Hs + | Html | Json | Keys | Lisp @@ -44,6 +46,7 @@ data Ext | Rs | Scm | Sh + | Toml deriving (Eq, Show, Generic, Aeson.ToJSON, Ord) data Namespace = Namespace {path :: [String], ext :: Ext} @@ -65,9 +68,11 @@ toPath (Namespace parts ext) = toExt :: Ext -> String toExt = ("." <>) <. \case + Bash -> "bash" C -> "c" Css -> "css" Hs -> "hs" + Html -> "html" Json -> "json" Keys -> "pub" Lisp -> "lisp" @@ -78,6 +83,7 @@ toExt = Rs -> "rs" Scm -> "scm" Sh -> "sh" + Toml -> "toml" fromHaskellContent :: String -> Maybe Namespace fromHaskellContent c = case Regex.findFirstInfix haskellModule c of @@ -95,6 +101,7 @@ toModule (Namespace parts Py) = joinWith "." parts toModule (Namespace parts Scm) = "(" ++ joinWith " " parts ++ ")" toModule (Namespace parts Rs) = joinWith "::" parts toModule (Namespace parts C) = joinWith "/" parts <> ".c" +toModule (Namespace parts Nix) = joinWith "/" parts <> ".nix" toModule (Namespace {..}) = panic <| "toModule not implemented for " <> show ext toHaskellModule :: Namespace -> String @@ -115,7 +122,10 @@ dot = Regex.some <| Regex.sym '.' name :: Regex.RE Char String name = Regex.many (Regex.psym Char.isUpper) - <> Regex.many (Regex.psym (\c -> Char.isAlphaNum c || (c == '_'))) + <> ( Regex.many + <| Regex.psym + <| \c -> Char.isAlphaNum c || c == '_' || c == '-' + ) rePath :: Regex.RE Char [String] rePath = Regex.many (name <* Regex.string "/" <|> name) @@ -125,6 +135,7 @@ reExt = C <$ Regex.string "c" <|> Css <$ Regex.string "css" <|> Hs <$ Regex.string "hs" + <|> Html <$ Regex.string "html" <|> Json <$ Regex.string "json" <|> Keys <$ Regex.string "pub" <|> Lisp <$ Regex.string "lisp" @@ -134,6 +145,8 @@ reExt = <|> Rs <$ Regex.string "rs" <|> Scm <$ Regex.string "scm" <|> Sh <$ Regex.string "sh" + <|> Bash <$ Regex.string "bash" + <|> Toml <$ Regex.string "toml" -- | The cab dir is for temporary files and build outputs, not for source -- inputs. |