Conversation
|
Sorry I missed this. I don't see how this is type safe though. If |
|
Good points. Maybe the alternative to go the type class direction (#136 (comment)) would be safer. I would definitely be open to writing this that way. What do you think? |
|
I think row types are a fine fit, but treating it as a record is not safe for two reasons:
I think you could possibly provide an opaque |
|
Thanks. Along these lines sounds good. I was testing out the following. Is this kind of like what you are suggesting? foreign import data SyntheticEvent_ :: # Type -> Type
type SyntheticEventRow r
= ( bubbles :: Boolean
, cancelable :: Boolean
, currentTarget :: NativeEventTarget
, defaultPrevented :: Boolean
, eventPhase :: Number
, isTrusted :: Boolean
, nativeEvent :: NativeEvent
, target :: NativeEventTarget
, timeStamp :: Number
, type :: String
| r
)
type SyntheticUIEventRow r
= ( detail :: Number
, view :: NativeAbstractView
| r
)
get
:: forall eff l r s a
. RowCons l a r s
=> IsSymbol l
=> SProxy l
-> SyntheticEvent_ s
-> Eff eff a
get l r = unsafeGet (reflectSymbol l) r
foreign import unsafeGet :: forall eff r a. String -> SyntheticEvent_ r -> Eff eff a
type SyntheticEvent'' r = SyntheticEvent_ (SyntheticEventRow r)
type SyntheticUIEvent'' = SyntheticEvent_ (SyntheticUIEventRow (SyntheticEventRow ()))
bubbles :: forall eff r. SyntheticEvent'' r -> Eff eff Boolean
bubbles = get (SProxy :: SProxy "bubbles")
detail :: forall eff. SyntheticUIEvent'' -> Eff eff Number
detail = get (SProxy :: SProxy "detail") |
|
Yes, exactly. |
|
Great! I will send a PR for this, probably tomorrow.
…On Sat, Apr 14, 2018 at 16:14 Nathan Faubion ***@***.***> wrote:
Yes, exactly.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#140 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVYy3Z1MmoaMpS23oO5yESx5ua8Si2aks5toli-gaJpZM4TOPz1>
.
|
Initial work for updating the representation of events. This is still a work in progress, but putting up what I have so far.
Resolves #85
Resolves #135
Resolves #136
@natefaubion @unclechu @arthurxavierx - Any feedback is most welcome.