|
@@ -8,24 +8,34 @@ import Data.Char (toUpper)
|
|
|
|
|
|
import Gidl.Types
|
|
|
import Gidl.Interface
|
|
|
+import Gidl.Backend.Haskell.Types
|
|
|
import Ivory.Artifact
|
|
|
import Text.PrettyPrint.Mainland
|
|
|
|
|
|
interfaceModule :: [String] -> InterfaceRepr -> Artifact
|
|
|
-interfaceModule modulepath ir =
|
|
|
+interfaceModule modulepath ir@(InterfaceRepr iname i) =
|
|
|
artifactPath (intercalate "/" modulepath) $
|
|
|
artifactText ((ifModuleName ir) ++ ".hs") $
|
|
|
prettyLazyText 80 $
|
|
|
stack
|
|
|
[ text "module"
|
|
|
- <+> tm (ifModuleName ir)
|
|
|
+ <+> im (ifModuleName ir)
|
|
|
<+> text "where"
|
|
|
, empty
|
|
|
+ , stack [ text "import" <+> im (ifModuleName iir)
|
|
|
+ | iir <- interfaceParents i
|
|
|
+ ]
|
|
|
+ , stack $ map (importDecl tm)
|
|
|
+ $ nub
|
|
|
+ $ map importType
|
|
|
+ $ interfaceTypes ir
|
|
|
]
|
|
|
where
|
|
|
- tm mname = mconcat $ punctuate dot
|
|
|
+ im mname = mconcat $ punctuate dot
|
|
|
$ map text (modulepath ++ [mname])
|
|
|
-
|
|
|
+ tm mname = mconcat $ punctuate dot
|
|
|
+ $ map text (typepath modulepath ++ ["Types", mname])
|
|
|
+ where typepath = reverse . drop 1 . reverse
|
|
|
|
|
|
ifModuleName :: InterfaceRepr -> String
|
|
|
ifModuleName (InterfaceRepr iname _) = aux iname
|