3A very rough tool to generate compatible ELm and PS type definitions from a common YAML definition. I intend to use them to communicate through Elm ports.
8elm-ps-bridge --input example.yaml --elmOutput Bridge.elm --psOutput Bridge.purs
27-- File auto generated by purescript-bridge! --
30import Data.Generic.Rep (class Generic)
31import Data.Lens (Iso', Lens', Prism', lens, prism')
32import Data.Lens.Iso.Newtype (_Newtype)
33import Data.Lens.Record (prop)
34import Data.Maybe (Maybe(..))
35import Data.Newtype (class Newtype)
36import Data.Symbol (SProxy(SProxy))
43derive instance genericCommand :: Generic Command _
44derive instance newtypeCommand :: Newtype Command _
45derive instance eqCommand :: Eq Command
46derive instance ordCommand :: Ord Command
48--------------------------------------------------------------------------------
49_Hello :: Prism' Command Unit
50_Hello = prism' (\_ -> Hello) f
54--------------------------------------------------------------------------------
55newtype Subscription_UpdatePassword =
56 Subscription_UpdatePassword {
61derive instance genericSubscription_UpdatePassword :: Generic Subscription_UpdatePassword _
62derive instance newtypeSubscription_UpdatePassword :: Newtype Subscription_UpdatePassword _
63derive instance eqSubscription_UpdatePassword :: Eq Subscription_UpdatePassword
64derive instance ordSubscription_UpdatePassword :: Ord Subscription_UpdatePassword
66--------------------------------------------------------------------------------
67_Subscription_UpdatePassword :: Iso' Subscription_UpdatePassword { foo :: Int, id :: Int}
68_Subscription_UpdatePassword = _Newtype
70--------------------------------------------------------------------------------
73 | UpdatePassword Subscription_UpdatePassword
75derive instance genericSubscription :: Generic Subscription _
76derive instance newtypeSubscription :: Newtype Subscription _
77derive instance eqSubscription :: Eq Subscription
78derive instance ordSubscription :: Ord Subscription
80--------------------------------------------------------------------------------
81_DownloadPasswords :: Prism' Subscription Unit
82_DownloadPasswords = prism' (\_ -> DownloadPasswords) f
84 f DownloadPasswords = Just unit
87_UpdatePassword :: Prism' Subscription Subscription_UpdatePassword
88_UpdatePassword = prism' UpdatePassword f
90 f (UpdatePassword a) = Just $ a
93--------------------------------------------------------------------------------
99module Bridge exposing(..)
102import Json.Encode exposing (Value)
103-- The following module comes from bartavelle/json-helpers
104import Json.Helpers exposing (..)
105import Dict exposing (Dict)
106import Set exposing (Set)
112jsonDecCommand : Json.Decode.Decoder ( Command )
114 let jsonDecDictCommand = Dict.fromList [("Hello", Hello)]
115 in decodeSumUnaries "Command" jsonDecDictCommand
117jsonEncCommand : Command -> Value
120 Hello -> Json.Encode.string "Hello"
124type alias Subscription_UpdatePassword =
129jsonDecSubscription_UpdatePassword : Json.Decode.Decoder ( Subscription_UpdatePassword )
130jsonDecSubscription_UpdatePassword =
131 Json.Decode.succeed (\pfoo pid -> {foo = pfoo, id = pid})
132 |> required "foo" (Json.Decode.int)
133 |> required "id" (Json.Decode.int)
135jsonEncSubscription_UpdatePassword : Subscription_UpdatePassword -> Value
136jsonEncSubscription_UpdatePassword val =
138 [ ("foo", Json.Encode.int val.foo)
139 , ("id", Json.Encode.int val.id)
146 | UpdatePassword Subscription_UpdatePassword
148jsonDecSubscription : Json.Decode.Decoder ( Subscription )
150 let jsonDecDictSubscription = Dict.fromList
151 [ ("DownloadPasswords", Json.Decode.lazy (\_ -> Json.Decode.succeed DownloadPasswords))
152 , ("UpdatePassword", Json.Decode.lazy (\_ -> Json.Decode.map UpdatePassword (jsonDecSubscription_UpdatePassword)))
154 in decodeSumObjectWithSingleField "Subscription" jsonDecDictSubscription
156jsonEncSubscription : Subscription -> Value
157jsonEncSubscription val =
158 let keyval v = case v of
159 DownloadPasswords -> ("DownloadPasswords", encodeValue (Json.Encode.list identity []))
160 UpdatePassword v1 -> ("UpdatePassword", encodeValue (jsonEncSubscription_UpdatePassword v1))
161 in encodeSumObjectWithSingleField keyval val
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list