on master help sign in
Improve indentation in Transform.Canonicalize.Setup
b10c2eaEvan Czaplicki
src/Transform/Canonicalize/Setup.hs+29−13
@@ -28,7 +28,10 @@ import qualified Transform.Canonicalize.Type as Canonicalize
28import qualified Transform.Interface as Interface
28import qualified Transform.Interface as Interface
29
29
30
30
31+environment
32+ :: Module.Interfaces
33+ -> Module.ValidModule
31−environment :: Module.Interfaces -> Module.ValidModule -> Canonicalizer [Doc] Environment
34+ -> Canonicalizer [Doc] Environment
32environment interfaces modul@(Module.Module _ _ _ imports decls) =
35environment interfaces modul@(Module.Module _ _ _ imports decls) =
33 do () <- allImportsAvailable
36 do () <- allImportsAvailable
34 let moduleName =
37 let moduleName =
@@ -186,12 +189,23 @@ node name tvars alias =
186 where
189 where
187 edges tipe =
190 edges tipe =
188 case tipe of
191 case tipe of
189− Type.Lambda t1 t2 -> edges t1 ++ edges t2
192+ Type.Lambda t1 t2 ->
193+ edges t1 ++ edges t2
194+
190− Type.Var _ -> []
195+ Type.Var _ ->
196+ []
197+
191− Type.Type (Var.Raw x) -> [x]
198+ Type.Type (Var.Raw x) ->
199+ [x]
200+
201+ Type.App t ts ->
192− Type.App t ts -> edges t ++ concatMap edges ts
202+ edges t ++ concatMap edges ts
203+
204+ Type.Record fs ext ->
193− Type.Record fs ext -> maybe [] edges ext ++ concatMap (edges . snd) fs
205+ maybe [] edges ext ++ concatMap (edges . snd) fs
206+
194− Type.Aliased _ t -> edges t
207+ Type.Aliased _ t ->
208+ edges t
195
209
196
210
197addTypeAliases
211addTypeAliases
@@ -233,22 +247,23 @@ addTypeAlias moduleName env scc =
233
247
234typeAlias
248typeAlias
235 :: (String, [String], Type.Type var)
249 :: (String, [String], Type.Type var)
236− -> D.Declaration' port def var
250+ -> D.Declaration' wire def var
237typeAlias (n,ts,t) =
251typeAlias (n,ts,t) =
238 D.TypeAlias n ts t
252 D.TypeAlias n ts t
239
253
240
254
241datatype
255datatype
242 :: (String, [String], Type.Type var)
256 :: (String, [String], Type.Type var)
243− -> D.Declaration' port def var
257+ -> D.Declaration' wire def var
244datatype (n,ts,t) =
258datatype (n,ts,t) =
245 D.Datatype n ts [(n,[t])]
259 D.Datatype n ts [(n,[t])]
246
260
247
261
248indented :: [D.ValidDecl] -> Doc
262indented :: [D.ValidDecl] -> Doc
263+indented decls =
249−indented decls = P.vcat (map prty decls) <> P.text "\n"
264+ P.vcat (map prty decls) <> P.text "\n"
250− where
265+ where
251− prty decl = P.text "\n " <> pretty decl
266+ prty decl = P.text "\n " <> pretty decl
252
267
253
268
254mutuallyRecursiveMessage :: String
269mutuallyRecursiveMessage :: String
@@ -317,4 +332,5 @@ addDecl moduleName info@(nodes,env) decl =
317 addLocal (D.wireName wire) (_values env)
332 addLocal (D.wireName wire) (_values env)
318 }
333 }
319
334
320− D.Fixity _ _ _ -> info
335+ D.Fixity _ _ _ ->
336+ info