@@ -15,8 +15,13 @@ import Language.PureScript.Sugar.Names.Env (primEnv)
1515import Language.PureScript.TypeChecker (typeCheckModule , emptyCheckState , debugType )
1616import Text.Pretty.Simple (pPrint )
1717import Data.String (String )
18+ import Language.PureScript.AST.Binders (Binder (.. ))
19+ import Debug.Pretty.Simple (pTraceShow )
1820
19- data NodeContext = DeclarationNode | ExpressionNode
21+ data NodeContext
22+ = DeclarationNode
23+ | BinderNode
24+ | ExpressionNode
2025 deriving (Show )
2126
2227data NodeInfo a = NodeInfo
@@ -69,8 +74,8 @@ mergeASTs xs@(x : xr) ys@(y : yr)
6974source :: Text
7075source = unlines
7176 [ " module Main where"
72- , " values :: Array Int"
73- , " values = [0, 1 ]"
77+ , " values :: Int -> Array Int"
78+ , " values x = [x ]"
7479 ]
7580
7681main :: IO ()
@@ -90,21 +95,32 @@ main = do
9095
9196 where
9297 declarationToAST :: Declaration -> [InterfaceAST String ]
93- (declarationToAST, _, _, _, _) = everythingOnValues mergeASTs onDecl onExpr noAST noAST noAST
98+ (declarationToAST, _, _, _, _) = everythingOnValues mergeASTs onDecl onExpr onBinder noAST noAST
9499 where
95100 noAST :: forall a . a -> [InterfaceAST String ]
96101 noAST = const []
97102
98103 onDecl :: Declaration -> [InterfaceAST String ]
99104 onDecl = \ case
100- ValueDecl (s, _) _ _ _ [MkUnguarded (TypedValue _ (PositionedValue _ _ _) t)] ->
101- [ makeNode (NodeInfo (debugType t) DeclarationNode ) s ]
102- _ ->
103- []
105+ -- ValueDecl (s, _) _ _ _ [MkUnguarded (TypedValue _ (PositionedValue _ _ _) t)] ->
106+ -- [ makeNode (NodeInfo (debugType t) DeclarationNode) s ]
107+ e ->
108+ pTraceShow e []
104109
105110 onExpr :: Expr -> [InterfaceAST String ]
106111 onExpr = \ case
107112 TypedValue _ (PositionedValue s _ _) t ->
108113 [ makeNode (NodeInfo (debugType t) ExpressionNode ) s ]
109114 _ ->
110115 []
116+
117+ onBinder :: Binder -> [InterfaceAST String ]
118+ onBinder = \ case
119+ TypedBinder t (LiteralBinder s _) ->
120+ [ makeNode (NodeInfo (debugType t) BinderNode ) s ]
121+ TypedBinder t (VarBinder s _) ->
122+ [ makeNode (NodeInfo (debugType t) BinderNode ) s ]
123+ TypedBinder t (ConstructorBinder s _ _) ->
124+ [ makeNode (NodeInfo (debugType t) BinderNode ) s ]
125+ _ ->
126+ []
0 commit comments