From 477b9cfd417bfd37ee3293593cd7e725f656d9b8 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Mon, 24 Feb 2020 10:33:43 -0800 Subject: [PATCH 1/2] Update library to compile on upcoming 0.14.0 PS release (#113) --- src/React/Basic.purs | 2 +- src/React/Basic/Events.purs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/React/Basic.purs b/src/React/Basic.purs index 2cefd1d..b38c1a0 100644 --- a/src/React/Basic.purs +++ b/src/React/Basic.purs @@ -139,7 +139,7 @@ foreign import createComponent -- | identify the component. It receives the `ComponentSpec` as a prop and knows -- | how to defer behavior to it. It requires very specific props and is not useful by -- | itself from JavaScript. For JavaScript interop, see `toReactComponent`.__ -data Component props +foreign import data Component :: Type -> Type -- | `Self` represents the component instance at a particular point in time. -- | diff --git a/src/React/Basic/Events.purs b/src/React/Basic/Events.purs index 199fc1a..71b6f8c 100644 --- a/src/React/Basic/Events.purs +++ b/src/React/Basic/Events.purs @@ -17,7 +17,7 @@ import Data.Symbol (class IsSymbol, SProxy(SProxy)) import Effect (Effect) import Effect.Uncurried (EffectFn1, mkEffectFn1) import Prim.Row as Row -import Prim.RowList (kind RowList, class RowToList, Cons, Nil) +import Prim.RowList (class RowToList, RowList, Cons, Nil) import Record (delete, get, insert) import Type.Data.RowList (RLProxy(..)) @@ -77,7 +77,7 @@ handler_ = mkEffectFn1 <<< const syntheticEvent :: EventFn SyntheticEvent SyntheticEvent syntheticEvent = identity -class Merge (rl :: RowList) fns a r | rl -> fns, rl a -> r where +class Merge (rl :: RowList Type) fns a r | rl -> fns, rl a -> r where mergeImpl :: RLProxy rl -> Record fns -> EventFn a (Record r) instance mergeNil :: Merge Nil () a () where From a0ab4b0c527c8f88f21d5dc68e4d09ca2d474cc8 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Sat, 18 Jul 2020 23:51:05 +0200 Subject: [PATCH 2/2] Add roles declarations to allow safe coercions --- src/React/Basic.purs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/React/Basic.purs b/src/React/Basic.purs index b38c1a0..aca284e 100644 --- a/src/React/Basic.purs +++ b/src/React/Basic.purs @@ -141,6 +141,8 @@ foreign import createComponent -- | itself from JavaScript. For JavaScript interop, see `toReactComponent`.__ foreign import data Component :: Type -> Type +type role Component representational + -- | `Self` represents the component instance at a particular point in time. -- | -- | - `props` @@ -347,14 +349,20 @@ foreign import displayNameFromSelf -- | __*See also:* `element`, `toReactComponent`__ foreign import data ReactComponent :: Type -> Type +type role ReactComponent representational + -- | An opaque representation of a React component's instance (`this` in the JavaScript -- | React paradigm). It exists as an escape hatch to unsafe behavior. Use it with -- | caution. foreign import data ReactComponentInstance :: Type -> Type -> Type +type role ReactComponentInstance representational representational + -- | A React Ref, as created by `React.createRef` foreign import data Ref :: Type -> Type +type role Ref representational + -- | Convert a React-Basic `ComponentSpec` to a JavaScript-friendly React component. -- | This function should only be used for JS interop and not normal React-Basic usage. -- | @@ -374,6 +382,8 @@ foreign import toReactComponent foreign import data ReactContext :: Type -> Type +type role ReactContext representational + -- | Create a `ReactContext` given a default value. Use `provider` and `consumer` -- | to provide and consume context values. Alternatively, use `contextProvider` -- | and `contextConsumer` directly if a `ReactComponent` is required for interop.