@@ -12,7 +12,7 @@ import qualified Text.Pandoc as Pan
12import Unique
12import Unique
13import Generate.Cases
13import Generate.Cases
14import SourceSyntax.Everything hiding (parens)
14import SourceSyntax.Everything hiding (parens)
15−import SourceSyntax.Location as Loc
15+import SourceSyntax.Location
16import qualified Transform.SortDefinitions as SD
16import qualified Transform.SortDefinitions as SD
18deprime :: String -> String
18deprime :: String -> String
@@ -130,12 +130,12 @@ instance ToJS (Def t v) where
130 | isOp x = globalAssign ("_op['" ++ x ++ "']") `liftM` toJS' e
130 | isOp x = globalAssign ("_op['" ++ x ++ "']") `liftM` toJS' e
131 | otherwise = assign (deprime x) `liftM` toJS' e
131 | otherwise = assign (deprime x) `liftM` toJS' e
133− toJS (Def pattern e) =
133+ toJS (Def pattern e@(L s _)) =
134 do n <- guid
134 do n <- guid
135 let x = "_" ++ show n
135 let x = "_" ++ show n
136− var = Loc.none . Var
136+ var = L s . Var
137 toDef y' = let y = deprime y' in
137 toDef y' = let y = deprime y' in
138− Def (PVar y) (Loc.none $ Case (var x) [(pattern, var y)])
138+ Def (PVar y) (L s $ Case (var x) [(pattern, var y)])
139 stmt <- assign x `liftM` toJS' e
139 stmt <- assign x `liftM` toJS' e
140 vars <- toJS . map toDef . Set.toList $ SD.boundVars pattern
140 vars <- toJS . map toDef . Set.toList $ SD.boundVars pattern
141 return (stmt ++ vars)
141 return (stmt ++ vars)
@@ -196,7 +196,7 @@ instance ToJS (Expr t v) where
196 Record fs -> makeRecord fs
196 Record fs -> makeRecord fs
197 Binop op e1 e2 -> binop op `liftM` toJS' e1 `ap` toJS' e2
197 Binop op e1 e2 -> binop op `liftM` toJS' e1 `ap` toJS' e2
199− Lambda p e -> liftM (fastFunc . ret) (toJS' body)
199+ Lambda p e@(L s _) -> liftM (fastFunc . ret) (toJS' body)
201 fastFunc body
201 fastFunc body
202 | length args < 2 || length args > 9 = foldr jsFunc body args
202 | length args < 2 || length args > 9 = foldr jsFunc body args
@@ -207,7 +207,7 @@ instance ToJS (Expr t v) where
207 case pattern of
207 case pattern of
208 PVar x -> (deprime x : args, body)
208 PVar x -> (deprime x : args, body)
209 _ -> let arg = "arg" ++ show n
209 _ -> let arg = "arg" ++ show n
210− in (arg:args, Loc.none (Case (Loc.none (Var arg)) [(pattern, body)]))
210+ in (arg:args, L s (Case (L s (Var arg)) [(pattern, body)]))
212 (patterns, innerBody) = collect [p] e
212 (patterns, innerBody) = collect [p] e