@@ -13,30 +13,35 @@ crawlLet
1313 -> Expr ann def var
1414 -> Either a (Expr ann def' var)
1515crawlLet =
16− crawl (\_ _ -> return ()) (\_ _ -> return ())
16+ crawl
17+ (\_ _ -> return ())
18+ (\_ _ -> return ())
19+ (\_ _ _ -> return ())
1720
1821
1922checkWires
2023 :: (String -> CanonicalType -> Either a ())
2124 -> (String -> CanonicalType -> Either a ())
25+ -> (String -> CanonicalType -> Bool -> Either a ())
2226 -> Canonical.Expr
2327 -> Either a Canonical.Expr
24−checkWires inputCheck outputCheck expr =
25− crawl inputCheck outputCheck (mapM checkDef) expr
28+checkWires inputCheck outputCheck loopbackCheck expr =
29+ crawl inputCheck outputCheck loopbackCheck (mapM checkDef) expr
2630 where
2731 checkDef def@(Canonical.Definition _ body _) =
28− do _ <- checkWires inputCheck outputCheck body
32+ do _ <- checkWires inputCheck outputCheck loopbackCheck body
2933 return def
3034
3135
3236crawl
3337 :: (String -> Type var -> Either a ())
3438 -> (String -> Type var -> Either a ())
39+ -> (String -> Type var -> Bool -> Either a ())
3540 -> ([def] -> Either a [def'])
3641 -> Expr ann def var
3742 -> Either a (Expr ann def' var)
38−crawl inputCheck outputCheck defsTransform =
39− go
43+crawl inputCheck outputCheck loopbackCheck defsTransform expression =
44+ go expression
4045 where
4146 go (A srcSpan expr) =
4247 A srcSpan <$>
@@ -101,8 +106,10 @@ crawl inputCheck outputCheck defsTransform =
101106 Output name st <$> go signal
102107
103108 Loopback name st maybeExpr ->
104− case maybeExpr of
105− Nothing ->
106− error "loopback check"
107− Just expr ->
108− error "loopback check"
109+ do let hasExpr = maybe False (const True) maybeExpr
110+ loopbackCheck name st hasExpr
111+ case maybeExpr of
112+ Nothing ->
113+ return (Loopback name st Nothing)
114+ Just expr ->
115+ (Loopback name st . Just) <$> go expr