on master help sign in
3 files changed+558−36
since splitsnapshots
unifiedsplit
flake.lock+454 flake.nix+35 src/Main.hs+69−36
flake.locknew file+454
@@ -0,0 +1,454 @@
1+{
2+ "nodes": {
3+ "HTTP": {
4+ "flake": false,
5+ "locked": {
6+ "lastModified": 1451647621,
7+ "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=",
8+ "owner": "phadej",
9+ "repo": "HTTP",
10+ "rev": "9bc0996d412fef1787449d841277ef663ad9a915",
11+ "type": "github"
12+ },
13+ "original": {
14+ "owner": "phadej",
15+ "repo": "HTTP",
16+ "type": "github"
17+ }
18+ },
19+ "cabal-32": {
20+ "flake": false,
21+ "locked": {
22+ "lastModified": 1603716527,
23+ "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=",
24+ "owner": "haskell",
25+ "repo": "cabal",
26+ "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee",
27+ "type": "github"
28+ },
29+ "original": {
30+ "owner": "haskell",
31+ "ref": "3.2",
32+ "repo": "cabal",
33+ "type": "github"
34+ }
35+ },
36+ "cabal-34": {
37+ "flake": false,
38+ "locked": {
39+ "lastModified": 1640353650,
40+ "narHash": "sha256-N1t6M3/wqj90AEdRkeC8i923gQYUpzSr8b40qVOZ1Rk=",
41+ "owner": "haskell",
42+ "repo": "cabal",
43+ "rev": "942639c18c0cd8ec53e0a6f8d120091af35312cd",
44+ "type": "github"
45+ },
46+ "original": {
47+ "owner": "haskell",
48+ "ref": "3.4",
49+ "repo": "cabal",
50+ "type": "github"
51+ }
52+ },
53+ "cabal-36": {
54+ "flake": false,
55+ "locked": {
56+ "lastModified": 1641652457,
57+ "narHash": "sha256-BlFPKP4C4HRUJeAbdembX1Rms1LD380q9s0qVDeoAak=",
58+ "owner": "haskell",
59+ "repo": "cabal",
60+ "rev": "f27667f8ec360c475027dcaee0138c937477b070",
61+ "type": "github"
62+ },
63+ "original": {
64+ "owner": "haskell",
65+ "ref": "3.6",
66+ "repo": "cabal",
67+ "type": "github"
68+ }
69+ },
70+ "cardano-shell": {
71+ "flake": false,
72+ "locked": {
73+ "lastModified": 1608537748,
74+ "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=",
75+ "owner": "input-output-hk",
76+ "repo": "cardano-shell",
77+ "rev": "9392c75087cb9a3d453998f4230930dea3a95725",
78+ "type": "github"
79+ },
80+ "original": {
81+ "owner": "input-output-hk",
82+ "repo": "cardano-shell",
83+ "type": "github"
84+ }
85+ },
86+ "flake-compat": {
87+ "flake": false,
88+ "locked": {
89+ "lastModified": 1632802058,
90+ "narHash": "sha256-7IySNHriQjzOZ88DDk6VDPf1GoUaOrOeUdukY62o52o=",
91+ "owner": "hamishmack",
92+ "repo": "flake-compat",
93+ "rev": "5523c47f13259b981c49b26e28499724a5125fd8",
94+ "type": "github"
95+ },
96+ "original": {
97+ "owner": "hamishmack",
98+ "ref": "hkm/pkgs-fetch",
99+ "repo": "flake-compat",
100+ "type": "github"
101+ }
102+ },
103+ "flake-utils": {
104+ "locked": {
105+ "lastModified": 1659877975,
106+ "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
107+ "owner": "numtide",
108+ "repo": "flake-utils",
109+ "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
110+ "type": "github"
111+ },
112+ "original": {
113+ "owner": "numtide",
114+ "repo": "flake-utils",
115+ "type": "github"
116+ }
117+ },
118+ "flake-utils_2": {
119+ "locked": {
120+ "lastModified": 1644229661,
121+ "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
122+ "owner": "numtide",
123+ "repo": "flake-utils",
124+ "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
125+ "type": "github"
126+ },
127+ "original": {
128+ "owner": "numtide",
129+ "repo": "flake-utils",
130+ "type": "github"
131+ }
132+ },
133+ "ghc-8.6.5-iohk": {
134+ "flake": false,
135+ "locked": {
136+ "lastModified": 1600920045,
137+ "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=",
138+ "owner": "input-output-hk",
139+ "repo": "ghc",
140+ "rev": "95713a6ecce4551240da7c96b6176f980af75cae",
141+ "type": "github"
142+ },
143+ "original": {
144+ "owner": "input-output-hk",
145+ "ref": "release/8.6.5-iohk",
146+ "repo": "ghc",
147+ "type": "github"
148+ }
149+ },
150+ "hackage": {
151+ "flake": false,
152+ "locked": {
153+ "lastModified": 1662772451,
154+ "narHash": "sha256-ilkCYrbktOl1kvMJ/zRZaoS41AVabHgaeUNfpwvDgW4=",
155+ "owner": "input-output-hk",
156+ "repo": "hackage.nix",
157+ "rev": "18aa3d7550a3eee83a0aee1246406c9add46fd2e",
158+ "type": "github"
159+ },
160+ "original": {
161+ "owner": "input-output-hk",
162+ "repo": "hackage.nix",
163+ "type": "github"
164+ }
165+ },
166+ "haskellNix": {
167+ "inputs": {
168+ "HTTP": "HTTP",
169+ "cabal-32": "cabal-32",
170+ "cabal-34": "cabal-34",
171+ "cabal-36": "cabal-36",
172+ "cardano-shell": "cardano-shell",
173+ "flake-compat": "flake-compat",
174+ "flake-utils": "flake-utils_2",
175+ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk",
176+ "hackage": "hackage",
177+ "hpc-coveralls": "hpc-coveralls",
178+ "hydra": "hydra",
179+ "nix-tools": "nix-tools",
180+ "nixpkgs": [
181+ "haskellNix",
182+ "nixpkgs-unstable"
183+ ],
184+ "nixpkgs-2003": "nixpkgs-2003",
185+ "nixpkgs-2105": "nixpkgs-2105",
186+ "nixpkgs-2111": "nixpkgs-2111",
187+ "nixpkgs-2205": "nixpkgs-2205",
188+ "nixpkgs-unstable": "nixpkgs-unstable",
189+ "old-ghc-nix": "old-ghc-nix",
190+ "stackage": "stackage"
191+ },
192+ "locked": {
193+ "lastModified": 1662786284,
194+ "narHash": "sha256-4ArqOMoul3PXeIO0BPfARBlJJ4dSYnRZl//cKzVcEww=",
195+ "owner": "input-output-hk",
196+ "repo": "haskell.nix",
197+ "rev": "20c33afad920746af56329f7a92423c244bfabbe",
198+ "type": "github"
199+ },
200+ "original": {
201+ "owner": "input-output-hk",
202+ "repo": "haskell.nix",
203+ "type": "github"
204+ }
205+ },
206+ "hpc-coveralls": {
207+ "flake": false,
208+ "locked": {
209+ "lastModified": 1607498076,
210+ "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=",
211+ "owner": "sevanspowell",
212+ "repo": "hpc-coveralls",
213+ "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430",
214+ "type": "github"
215+ },
216+ "original": {
217+ "owner": "sevanspowell",
218+ "repo": "hpc-coveralls",
219+ "type": "github"
220+ }
221+ },
222+ "hydra": {
223+ "inputs": {
224+ "nix": "nix",
225+ "nixpkgs": [
226+ "haskellNix",
227+ "hydra",
228+ "nix",
229+ "nixpkgs"
230+ ]
231+ },
232+ "locked": {
233+ "lastModified": 1646878427,
234+ "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=",
235+ "owner": "NixOS",
236+ "repo": "hydra",
237+ "rev": "28b682b85b7efc5cf7974065792a1f22203a5927",
238+ "type": "github"
239+ },
240+ "original": {
241+ "id": "hydra",
242+ "type": "indirect"
243+ }
244+ },
245+ "lowdown-src": {
246+ "flake": false,
247+ "locked": {
248+ "lastModified": 1633514407,
249+ "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
250+ "owner": "kristapsdz",
251+ "repo": "lowdown",
252+ "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
253+ "type": "github"
254+ },
255+ "original": {
256+ "owner": "kristapsdz",
257+ "repo": "lowdown",
258+ "type": "github"
259+ }
260+ },
261+ "nix": {
262+ "inputs": {
263+ "lowdown-src": "lowdown-src",
264+ "nixpkgs": "nixpkgs",
265+ "nixpkgs-regression": "nixpkgs-regression"
266+ },
267+ "locked": {
268+ "lastModified": 1643066034,
269+ "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=",
270+ "owner": "NixOS",
271+ "repo": "nix",
272+ "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62",
273+ "type": "github"
274+ },
275+ "original": {
276+ "owner": "NixOS",
277+ "ref": "2.6.0",
278+ "repo": "nix",
279+ "type": "github"
280+ }
281+ },
282+ "nix-tools": {
283+ "flake": false,
284+ "locked": {
285+ "lastModified": 1659569011,
286+ "narHash": "sha256-wHS0H5+TERmDnPCfzH4A+rSR5TvjYMWus9BNeNAMyUM=",
287+ "owner": "input-output-hk",
288+ "repo": "nix-tools",
289+ "rev": "555d57e1ea81b79945f2608aa261df20f6b602a5",
290+ "type": "github"
291+ },
292+ "original": {
293+ "owner": "input-output-hk",
294+ "repo": "nix-tools",
295+ "type": "github"
296+ }
297+ },
298+ "nixpkgs": {
299+ "locked": {
300+ "lastModified": 1632864508,
301+ "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=",
302+ "owner": "NixOS",
303+ "repo": "nixpkgs",
304+ "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234",
305+ "type": "github"
306+ },
307+ "original": {
308+ "id": "nixpkgs",
309+ "ref": "nixos-21.05-small",
310+ "type": "indirect"
311+ }
312+ },
313+ "nixpkgs-2003": {
314+ "locked": {
315+ "lastModified": 1620055814,
316+ "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=",
317+ "owner": "NixOS",
318+ "repo": "nixpkgs",
319+ "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205",
320+ "type": "github"
321+ },
322+ "original": {
323+ "owner": "NixOS",
324+ "ref": "nixpkgs-20.03-darwin",
325+ "repo": "nixpkgs",
326+ "type": "github"
327+ }
328+ },
329+ "nixpkgs-2105": {
330+ "locked": {
331+ "lastModified": 1655034179,
332+ "narHash": "sha256-rf1/7AbzuYDw6+8Xvvf3PtEOygymLBrFsFxvext5ZjI=",
333+ "owner": "NixOS",
334+ "repo": "nixpkgs",
335+ "rev": "046ee4af7a9f016a364f8f78eeaa356ba524ac31",
336+ "type": "github"
337+ },
338+ "original": {
339+ "owner": "NixOS",
340+ "ref": "nixpkgs-21.05-darwin",
341+ "repo": "nixpkgs",
342+ "type": "github"
343+ }
344+ },
345+ "nixpkgs-2111": {
346+ "locked": {
347+ "lastModified": 1656782578,
348+ "narHash": "sha256-1eMCBEqJplPotTo/SZ/t5HU6Sf2I8qKlZi9MX7jv9fw=",
349+ "owner": "NixOS",
350+ "repo": "nixpkgs",
351+ "rev": "573603b7fdb9feb0eb8efc16ee18a015c667ab1b",
352+ "type": "github"
353+ },
354+ "original": {
355+ "owner": "NixOS",
356+ "ref": "nixpkgs-21.11-darwin",
357+ "repo": "nixpkgs",
358+ "type": "github"
359+ }
360+ },
361+ "nixpkgs-2205": {
362+ "locked": {
363+ "lastModified": 1657876628,
364+ "narHash": "sha256-URmf0O2cQ/3heg2DJOeLyU/JmfVMqG4X5t9crQXMaeY=",
365+ "owner": "NixOS",
366+ "repo": "nixpkgs",
367+ "rev": "549d82bdd40f760a438c3c3497c1c61160f3de55",
368+ "type": "github"
369+ },
370+ "original": {
371+ "owner": "NixOS",
372+ "ref": "nixpkgs-22.05-darwin",
373+ "repo": "nixpkgs",
374+ "type": "github"
375+ }
376+ },
377+ "nixpkgs-regression": {
378+ "locked": {
379+ "lastModified": 1643052045,
380+ "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
381+ "owner": "NixOS",
382+ "repo": "nixpkgs",
383+ "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
384+ "type": "github"
385+ },
386+ "original": {
387+ "id": "nixpkgs",
388+ "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
389+ "type": "indirect"
390+ }
391+ },
392+ "nixpkgs-unstable": {
393+ "locked": {
394+ "lastModified": 1657888067,
395+ "narHash": "sha256-GnwJoFBTPfW3+mz7QEeJEEQ9OMHZOiIJ/qDhZxrlKh8=",
396+ "owner": "NixOS",
397+ "repo": "nixpkgs",
398+ "rev": "65fae659e31098ca4ac825a6fef26d890aaf3f4e",
399+ "type": "github"
400+ },
401+ "original": {
402+ "owner": "NixOS",
403+ "ref": "nixpkgs-unstable",
404+ "repo": "nixpkgs",
405+ "type": "github"
406+ }
407+ },
408+ "old-ghc-nix": {
409+ "flake": false,
410+ "locked": {
411+ "lastModified": 1631092763,
412+ "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=",
413+ "owner": "angerman",
414+ "repo": "old-ghc-nix",
415+ "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8",
416+ "type": "github"
417+ },
418+ "original": {
419+ "owner": "angerman",
420+ "ref": "master",
421+ "repo": "old-ghc-nix",
422+ "type": "github"
423+ }
424+ },
425+ "root": {
426+ "inputs": {
427+ "flake-utils": "flake-utils",
428+ "haskellNix": "haskellNix",
429+ "nixpkgs": [
430+ "haskellNix",
431+ "nixpkgs-unstable"
432+ ]
433+ }
434+ },
435+ "stackage": {
436+ "flake": false,
437+ "locked": {
438+ "lastModified": 1662772551,
439+ "narHash": "sha256-nv6u7nG2ep+BTGaOluEv/UY+Q8byCGPEHit5PvVI85U=",
440+ "owner": "input-output-hk",
441+ "repo": "stackage.nix",
442+ "rev": "f723a28a9dc39f10782338e0431fc2be578c3f3c",
443+ "type": "github"
444+ },
445+ "original": {
446+ "owner": "input-output-hk",
447+ "repo": "stackage.nix",
448+ "type": "github"
449+ }
450+ }
451+ },
452+ "root": "root",
453+ "version": 7
454+}
flake.nixnew file+35
@@ -0,0 +1,35 @@
1+{
2+ inputs = {
3+ flake-utils.url = "github:numtide/flake-utils";
4+ haskellNix.url = "github:input-output-hk/haskell.nix";
5+ nixpkgs.follows = "haskellNix/nixpkgs-unstable";
6+ };
7+ outputs = { self, nixpkgs, flake-utils, haskellNix }:
8+ flake-utils.lib.eachSystem [
9+ "x86_64-linux"
10+ "x86_64-darwin"
11+ "aarch64-linux"
12+ "aarch64-darwin"
13+ ]
14+ (system:
15+ let
16+ pkgs = import nixpkgs {
17+ overlays = [ haskellNix.overlay ];
18+ inherit system;
19+ inherit (haskellNix) config;
20+ };
21+
22+ project = pkgs.haskell-nix.project' {
23+ src = ./.;
24+ };
25+ flake = project.flake { };
26+ in
27+ flake //
28+ {
29+ apps.default = {
30+ type = "app";
31+ program = "${flake.packages."elm-ps-bridge:exe:elm-ps-bridge"}/bin/elm-ps-bridge";
32+ };
33+ }
34+ );
35+}
src/Main.hs+69−36
@@ -2,6 +2,7 @@ module Main (main) where
22
33import Control.Monad.Writer.Strict
44import Data.Aeson hiding (Options)
5+import Data.Aeson.Types
56import Data.HashMap.Strict qualified as HM
67import Data.Map.Lazy qualified as M
78import Data.Vector (Vector)
@@ -30,7 +31,9 @@ data Datatype
3031 | IntType
3132 | FloatType
3233 | StringType
34+ | CustomType Text
3335 | List Datatype
36+ | MaybeType Datatype
3437 deriving stock (Show)
3538
3639newtype SumType = SumType (Map Text (Maybe Datatype))
@@ -40,18 +43,22 @@ parseSumType :: Vector Value -> Parser SumType
4043parseSumType = fmap (SumType . fold) . traverse parseConstructor . V.toList
4144 where
4245 parseConstructor (String s) = pure $ one (s, Nothing)
43− parseConstructor (Object o) | [(k, v)] <- HM.toList o = one . (k,) . Just <$> parseJSON v
46+ parseConstructor (Object o)
47+ | [(k, v)] <- HM.toList o =
48+ prependFailure ("in constructor " <> toString k <> ", ") $ one . (k,) . Just <$> parseJSON v
4449 parseConstructor (Object _) = fail "Sum types can only have one name per constructor"
4550 parseConstructor _ = fail "Sum Bad sum type ;("
4651
4752instance FromJSON Datatype where
48− parseJSON (Array a) = SumDatatype <$> parseSumType a
49− parseJSON (Object o) | [("List", x)] <- HM.toList o = List <$> parseJSON x
50− parseJSON (Object o) = ProductType <$> traverse parseJSON (M.fromList $ HM.toList o)
53+ parseJSON (Array a) = prependFailure "in Sum, " $ SumDatatype <$> parseSumType a
54+ parseJSON (Object o) | [("List", x)] <- HM.toList o = prependFailure "in List, " $ List <$> parseJSON x
55+ parseJSON (Object o) | [("Maybe", x)] <- HM.toList o = prependFailure "in Maybe, " $ MaybeType <$> parseJSON x
56+ parseJSON (Object o) = prependFailure "in Record, " $ ProductType <$> traverse parseJSON (M.fromList $ HM.toList o)
5157 parseJSON (String "Bool") = pure BoolType
5258 parseJSON (String "Int") = pure IntType
5359 parseJSON (String "Float") = pure FloatType
5460 parseJSON (String "String") = pure StringType
61+ parseJSON (String t) = pure $ CustomType t
5562 parseJSON _ = fail "Bad datatype ;("
5663
5764data Options = Options
@@ -67,26 +74,36 @@ elm datattypes =
6774 let (_, types) = runWriter $ traverse (uncurry elmType) $ M.toList datattypes
6875 in makeElmModuleFromETypeDef "Bridge" types
6976
70−elmType :: Text -> Datatype -> Writer [ETypeDef] EType
71−elmType _ BoolType = pure $ ETyCon $ ETCon "Bool"
72−elmType _ IntType = pure $ ETyCon $ ETCon "Int"
73−elmType _ FloatType = pure $ ETyCon $ ETCon "Float"
74−elmType _ StringType = pure $ ETyCon $ ETCon "String"
75−elmType name (List inner) = do
76− -- fields' <- traverse (\(k, v) -> (toString k,) <$> elmType (name <> "_" <> k) v) $ M.toList fields
77− inner' <- elmType name inner
77+simpleElmAlias :: String -> EType -> Writer [ETypeDef] EType
78+simpleElmAlias name inner = do
7879 tell
7980 [ ETypePrimAlias
8081 EPrimAlias
8182 { epa_name =
8283 ETypeName
83− { et_name = toString name <> "_List",
84+ { et_name = name,
8485 et_args = []
8586 },
86− epa_type = ETyApp (ETyCon (ETCon "List")) inner'
87+ epa_type = inner
8788 }
8889 ]
89− pure $ ETyCon $ ETCon $ toString name
90+ pure $ ETyCon $ ETCon name
91+
92+elAp :: String -> EType -> EType
93+elAp con inner = ETyApp (ETyCon (ETCon con)) inner
94+
95+elmType :: Text -> Datatype -> Writer [ETypeDef] EType
96+elmType _ BoolType = pure $ ETyCon $ ETCon "Bool"
97+elmType _ IntType = pure $ ETyCon $ ETCon "Int"
98+elmType _ FloatType = pure $ ETyCon $ ETCon "Float"
99+elmType _ StringType = pure $ ETyCon $ ETCon "String"
100+elmType _ (CustomType t) = pure $ ETyCon $ ETCon $ toString t
101+elmType name (List inner) = do
102+ inner' <- elmType name inner
103+ simpleElmAlias (toString name <> "_List") (elAp "List" inner')
104+elmType name (MaybeType inner) = do
105+ inner' <- elmType name inner
106+ simpleElmAlias (toString name <> "_Maybe") (elAp "Maybe" inner')
90107elmType name (ProductType fields) = do
91108 fields' <- traverse (\(k, v) -> (toString k,) <$> elmType (name <> "_" <> k) v) $ M.toList fields
92109 tell
@@ -122,7 +139,7 @@ elmType name (SumDatatype (SumType sums)) = do
122139 _stcFields = Anonymous $ maybeToList value
123140 },
124141 es_omit_null = False,
125− es_unary_strings = False,
142+ es_unary_strings = True,
126143 es_type =
127144 SumEncoding'
128145 TaggedObject
@@ -133,39 +150,55 @@ elmType name (SumDatatype (SumType sums)) = do
133150 ]
134151 pure $ ETyCon $ ETCon $ toString name
135152
136−psType :: Text -> Datatype -> Writer [PS.SumType PureScript] (PS.TypeInfo PureScript)
137−psType _ BoolType = pure psBool
138−psType _ IntType = pure psInt
139−psType _ FloatType = pure psNumber
140−psType _ StringType = pure psString
141−psType name (List inner) = do
142− inner' <- psType name inner
153+simplePSAlias :: Text -> TypeInfo PureScript -> Writer [PS.SumType PureScript] (TypeInfo PureScript)
154+simplePSAlias name inner = do
143155 let ti =
144156 TypeInfo
145157 { _typePackage = "bridge",
146158 _typeModule = "Bridge",
147− _typeName = name <> "_List",
159+ _typeName = name,
148160 _typeParameters = []
149161 }
150162 tell
151163 [ PS.SumType
152164 ti
153165 [ DataConstructor
154− { _sigConstructor = name <> "_List",
155− _sigValues =
156− Left
157− [ TypeInfo
158− { _typePackage = "builtins",
159− _typeModule = "Prim",
160− _typeName = "Array",
161− _typeParameters = [inner']
162− }
163− ]
166+ { _sigConstructor = name,
167+ _sigValues = Left [inner]
164168 }
165169 ]
166− allInstances
170+ (PS.Newtype : allInstances)
167171 ]
168172 pure ti
173+
174+psAp :: Text -> Text -> Text -> TypeInfo lang -> TypeInfo lang
175+psAp package m t inner =
176+ TypeInfo
177+ { _typePackage = package,
178+ _typeModule = m,
179+ _typeName = t,
180+ _typeParameters = [inner]
181+ }
182+
183+psType :: Text -> Datatype -> Writer [PS.SumType PureScript] (PS.TypeInfo PureScript)
184+psType _ BoolType = pure psBool
185+psType _ IntType = pure psInt
186+psType _ FloatType = pure psNumber
187+psType _ StringType = pure psString
188+psType _ (CustomType t) = do
189+ pure
190+ TypeInfo
191+ { _typePackage = "bridge",
192+ _typeModule = "Bridge",
193+ _typeName = t,
194+ _typeParameters = []
195+ }
196+psType name (List inner) = do
197+ inner' <- psType name inner
198+ simplePSAlias (name <> "_List") (psAp "builtins" "Prim" "Array" inner')
199+psType name (MaybeType inner) = do
200+ inner' <- psType name inner
201+ simplePSAlias (name <> "_Maybe") (psAp "maybe" "Data.Maybe" "Maybe" inner')
169202psType name (SumDatatype (SumType sums)) = do
170203 sums' <- traverse (\(k, v) -> (k,) <$> traverse (psType (name <> "_" <> k)) v) $ M.toList sums
171204 let ti =
@@ -210,7 +243,7 @@ psType name (ProductType fields) = do
210243 }
211244 }
212245 ]
213− allInstances
246+ (PS.Newtype : allInstances)
214247 ]
215248 pure ti
216249