on master help sign in
Define NOINLINE versions of Int, Float, etc. in Elm.Name

Goal is to avoid allocating new versions.

commit07f61dcaaba88bea3c94606457dbfeda1c3ff206 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 1 Nov 2017, 16:36 (9 years ago) parent40e0c37
2 files changed+71−11
src/Canonicalize/Effects.hs+6−11 src/Elm/Name.hs+65
src/Canonicalize/Effects.hs+6−11
@@ -137,34 +137,29 @@ checkPayload tipe =
137137
138138isPrim :: ModuleName.Canonical -> N.Name -> Bool
139139isPrim home name =
140− home == ModuleName.basics
141− && Set.member name primitives
140+ home == ModuleName.basics && Set.member name primitives
142141
143142
144143primitives :: Set.Set Text
145144primitives =
146− Set.fromList [ "Int", "Float", "String", "Bool" ]
145+ Set.fromList [ N.int, N.float, N.string, N.bool ]
147146
148147
149148isJson :: ModuleName.Canonical -> N.Name -> Bool
150149isJson home name =
151− home == ModuleName.jsonEncode
152− && name == "Value"
150+ home == ModuleName.jsonEncode && name == "Value"
153151
154152
155153isList :: ModuleName.Canonical -> N.Name -> Bool
156154isList home name =
157− home == ModuleName.list
158− && name == "List"
155+ home == ModuleName.list && name == N.list
159156
160157
161158isMaybe :: ModuleName.Canonical -> N.Name -> Bool
162159isMaybe home name =
163− home == ModuleName.maybe
164− && name == "Maybe"
160+ home == ModuleName.maybe && name == N.maybe
165161
166162
167163isArray :: ModuleName.Canonical -> N.Name -> Bool
168164isArray home name =
169− home == ModuleName.array
170− && name == "Array"
165+ home == ModuleName.array && name == N.array
src/Elm/Name.hsnew file+65
@@ -0,0 +1,65 @@
1+{-# OPTIONS_GHC -Wall #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+module Elm.Name
4+ ( Name
5+ , toString
6+ , int, float, bool, char, string
7+ , maybe, list, array
8+ )
9+ where
10+
11+
12+import Prelude hiding (maybe)
13+import qualified Data.Text as Text
14+
15+
16+type Name = Text.Text
17+
18+
19+toString :: Name -> String
20+toString =
21+ Text.unpack
22+
23+
24+
25+-- COMMON NAMES
26+
27+
28+{-# NOINLINE int #-}
29+int :: Name
30+int = "Int"
31+
32+
33+{-# NOINLINE float #-}
34+float :: Name
35+float = "Float"
36+
37+
38+{-# NOINLINE bool #-}
39+bool :: Name
40+bool = "Bool"
41+
42+
43+{-# NOINLINE char #-}
44+char :: Name
45+char = "Char"
46+
47+
48+{-# NOINLINE string #-}
49+string :: Name
50+string = "String"
51+
52+
53+{-# NOINLINE maybe #-}
54+maybe :: Name
55+maybe = "Maybe"
56+
57+
58+{-# NOINLINE list #-}
59+list :: Name
60+list = "List"
61+
62+
63+{-# NOINLINE array #-}
64+array :: Name
65+array = "Array"