1{-# OPTIONS_GHC -Wall #-}
2module Transform.Expression (crawlLet, checkWires) where
4import Control.Applicative ((<$>),(<*>))
5import AST.Annotation ( Annotated(A) )
6import AST.Expression.General
7import qualified AST.Expression.Canonical as Canonical
8import AST.Type (Type, CanonicalType)
12 :: ([def] -> Either a [def'])
14 -> Either a (Expr ann def' var)
23 :: (String -> CanonicalType -> Either a ())
24 -> (String -> CanonicalType -> Either a ())
25 -> (String -> CanonicalType -> Bool -> Either a ())
27 -> Either a Canonical.Expr
28checkWires inputCheck outputCheck loopbackCheck expr =
29 crawl inputCheck outputCheck loopbackCheck (mapM checkDef) expr
31 checkDef def@(Canonical.Definition _ body _) =
32 do _ <- checkWires inputCheck outputCheck loopbackCheck body
37 :: (String -> Type var -> Either a ())
38 -> (String -> Type var -> Either a ())
39 -> (String -> Type var -> Bool -> Either a ())
40 -> ([def] -> Either a [def'])
42 -> Either a (Expr ann def' var)
43crawl inputCheck outputCheck loopbackCheck defsTransform expression =
56 Binop op <$> go e1 <*> go e2
59 Case <$> go e <*> mapM (\(p,b) -> (,) p <$> go b) cases
62 Data name <$> mapM go es
68 Range <$> go e1 <*> go e2
71 ExplicitList <$> mapM go es
74 App <$> go e1 <*> go e2
77 MultiIf <$> mapM (\(b,e) -> (,) <$> go b <*> go e) branches
80 Access <$> go e <*> return lbl
83 Remove <$> go e <*> return lbl
86 Insert <$> go e <*> return lbl <*> go v
89 Modify <$> go e <*> mapM (\(k,v) -> (,) k <$> go v) fields
92 Record <$> mapM (\(k,v) -> (,) k <$> go v) fields
95 Let <$> defsTransform defs <*> go body
97 GLShader uid src gltipe ->
98 return $ GLShader uid src gltipe
101 do inputCheck name st
102 return $ Input name st
104 Output name st signal ->
105 do outputCheck name st
106 Output name st <$> go signal
108 Loopback name st maybeExpr ->
109 do let hasExpr = maybe False (const True) maybeExpr
110 loopbackCheck name st hasExpr
113 return (Loopback name st Nothing)
115 (Loopback name st . Just) <$> go expr
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list