-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrintFile.hs
More file actions
26 lines (22 loc) · 1008 Bytes
/
PrintFile.hs
File metadata and controls
26 lines (22 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module PrintFile(printFile) where
import DataTypes
import PrintPort
import PrintInstance
import PrintPartition
import PrintAlias
printElement _ _ (Generic x) = return x
printElement _ _ (Include x) = return $ "import " ++ x ++ "::*;\nexport " ++ x ++ "::*;\n\n"
printElement _ _ x@(Alias {}) = printAlias x
printElement file filePortsAliases x@(Port {}) = printPort file filePortsAliases x
printElement _ _ x@(Instance {}) = printInstance x
printElement file filePortsAliases x@(Partition {}) = printPartition file filePortsAliases x
printFile file portsAliases elements = do
full <- foldl (\m1 elem -> do{x <- m1; y <- printElement file portsAliases elem; return $ x ++ y}) (return []) elements
return $
"import Vector::*;\n" ++
"import HaskellLib::*;\n" ++
"import Connectable::*;\n" ++
"import Base::*;\n" ++
"import Primitive::*;\n" ++
"export " ++ file ++ "::*;\n\n" ++
full