on master help sign in
Give more flexibility in adding indexes to names
a97552bEvan Czaplicki
src/Elm/Name.hs+4−4
@@ -6,7 +6,7 @@ module Elm.Name
6 , toString
6 , toString
7 , toBuilder
7 , toBuilder
8 , toShort
8 , toShort
9− , localFromInt
9+ , addIndex
10 , toCompositeName
10 , toCompositeName
11 , int, float, bool, char, string
11 , int, float, bool, char, string
12 , maybe, list, array, tuple
12 , maybe, list, array, tuple
@@ -53,9 +53,9 @@ toShort =
53 error "TODO"
53 error "TODO"
54
54
55
55
56−localFromInt :: Int -> Name
56+addIndex :: Name -> Int -> Name
57−localFromInt n =
57+addIndex name i =
58− Text.pack ('x' : show n)
58+ Text.append name (Text.pack (show i))
59
59
60
60
61toCompositeName :: Set.Set Name -> Name
61toCompositeName :: Set.Set Name -> Name
src/Optimize/Port.hs+2−2
@@ -268,7 +268,7 @@ decodeTuple a b maybeC =
268
268
269toLocal :: Int -> Opt.Expr
269toLocal :: Int -> Opt.Expr
270toLocal index =
270toLocal index =
271− Opt.VarLocal (N.localFromInt index)
271+ Opt.VarLocal (N.addIndex "x" index)
272
272
273
273
274indexAndThen :: Int -> Can.Type -> Opt.Expr -> Names.Tracker Opt.Expr
274indexAndThen :: Int -> Can.Type -> Opt.Expr -> Names.Tracker Opt.Expr
@@ -278,7 +278,7 @@ indexAndThen i tipe decoder =
278 typeDecoder <- toDecoder tipe
278 typeDecoder <- toDecoder tipe
279 return $
279 return $
280 Opt.Call andThen
280 Opt.Call andThen
281− [ Opt.Function [N.localFromInt i] decoder
281+ [ Opt.Function [N.addIndex "x" i] decoder
282 , Opt.Call index [ Opt.Int i, typeDecoder ]
282 , Opt.Call index [ Opt.Int i, typeDecoder ]
283 ]
283 ]
284
284