diff --git a/.travis.yml b/.travis.yml index c4cd216..8d604b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,13 @@ sudo: required language: node_js node_js: 10 +env: + - PATH=$HOME/purescript:$PATH install: + - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') + - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz + - tar -xvf $HOME/purescript.tar.gz -C $HOME/ + - chmod a+x $HOME/purescript - npm install script: diff --git a/bower.json b/bower.json index 7cdf91c..f8343ce 100644 --- a/bower.json +++ b/bower.json @@ -12,11 +12,11 @@ "url": "git://github.com/lumihq/purescript-react-basic.git" }, "dependencies": { - "purescript-functions": "^3.0.0", - "purescript-eff": "^3.1.0", - "purescript-unsafe-coerce": "^3.0.0", - "purescript-nullable": "^3.0.0", - "purescript-typelevel-prelude": "^2.6.0", - "purescript-record": "^0.2.6" + "purescript-functions": "^4.0.0", + "purescript-unsafe-coerce": "^4.0.0", + "purescript-nullable": "^4.0.0", + "purescript-typelevel-prelude": "^3.0.0", + "purescript-record": "^1.0.0", + "purescript-effect": "^2.0.0" } } diff --git a/codegen/package.json b/codegen/package.json index 9b57f88..d3e262a 100644 --- a/codegen/package.json +++ b/codegen/package.json @@ -5,6 +5,6 @@ "main": "index.js", "author": "", "dependencies": { - "react-html-attributes": "^1.4.1" + "react-html-attributes": "^1.4.2" } } diff --git a/package.json b/package.json index 3a03e6a..72d7d3b 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,7 @@ }, "homepage": "https://github.com/lumihq/purescript-react-basic#readme", "devDependencies": { - "bower": "^1.8.2", - "pulp": "^12.0.1", - "purescript": "^0.11.7" + "bower": "^1.8.4", + "pulp": "^12.2.0" } } diff --git a/src/React/Basic.purs b/src/React/Basic.purs index 0fe0df3..f0591f3 100644 --- a/src/React/Basic.purs +++ b/src/React/Basic.purs @@ -8,15 +8,13 @@ module React.Basic , fragmentKeyed , JSX , ReactComponent - , ReactFX ) where import Prelude -import Control.Monad.Eff (Eff, kind Effect) -import Control.Monad.Eff.Uncurried (EffFn3, mkEffFn3) import Data.Function.Uncurried (Fn2, Fn3, mkFn3, runFn2) -import Data.Monoid (class Monoid) +import Effect (Effect) +import Effect.Uncurried (EffectFn3, mkEffectFn3) import Unsafe.Coerce (unsafeCoerce) -- | A virtual DOM element. @@ -31,9 +29,6 @@ instance monoidJSX :: Monoid JSX where -- | A React component which can be used from JavaScript. foreign import data ReactComponent :: Type -> Type --- | A placeholder effect for all React FFI. -foreign import data ReactFX :: Effect - -- | Create a React component from a _specification_ of that component. -- | -- | A _specification_ consists of a state type, an initial value for that state, @@ -47,7 +42,7 @@ react :: forall props state fx . { displayName :: String , initialState :: { | state } - , receiveProps :: { | props } -> { | state } -> (SetState state fx) -> Eff (react :: ReactFX | fx) Unit + , receiveProps :: { | props } -> { | state } -> (SetState state fx) -> Effect Unit , render :: { | props } -> { | state } -> (SetState state fx) -> JSX } -> ReactComponent { | props } @@ -55,7 +50,7 @@ react { displayName, initialState, receiveProps, render } = component_ { displayName , initialState - , receiveProps: mkEffFn3 receiveProps + , receiveProps: mkEffectFn3 receiveProps , render: mkFn3 render } @@ -78,7 +73,7 @@ stateless { displayName, render } = } -- | SetState uses an update function to modify the current state. -type SetState state fx = ({ | state } -> { | state }) -> Eff (react :: ReactFX | fx) Unit +type SetState state fx = ({ | state } -> { | state }) -> Effect Unit -- | Create a `JSX` node from a React component, by providing the props. createElement @@ -119,7 +114,7 @@ foreign import component_ :: forall props state fx . { displayName :: String , initialState :: { | state } - , receiveProps :: EffFn3 (react :: ReactFX | fx) { | props } { | state } (SetState state fx) Unit + , receiveProps :: EffectFn3 { | props } { | state } (SetState state fx) Unit , render :: Fn3 { | props } { | state } (SetState state fx) JSX } -> ReactComponent { | props } diff --git a/src/React/Basic/DOM.purs b/src/React/Basic/DOM.purs index da8b625..b1b262c 100644 --- a/src/React/Basic/DOM.purs +++ b/src/React/Basic/DOM.purs @@ -7,6 +7,7 @@ module React.Basic.DOM where +import Prim.Row (class Union) import React.Basic (JSX, ReactComponent, createElement) import React.Basic.Events (EventHandler) import Unsafe.Coerce (unsafeCoerce) diff --git a/src/React/Basic/Events.purs b/src/React/Basic/Events.purs index cc773df..46931be 100644 --- a/src/React/Basic/Events.purs +++ b/src/React/Basic/Events.purs @@ -13,16 +13,17 @@ module React.Basic.Events import Prelude -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Uncurried (EffFn1, mkEffFn1) -import Data.Record (delete, get, insert) import Data.Symbol (class IsSymbol, SProxy(SProxy)) -import React.Basic (ReactFX) -import Type.Row (kind RowList, class RowToList, class RowLacks, RLProxy(..), Cons, Nil) +import Effect (Effect) +import Effect.Uncurried (EffectFn1, mkEffectFn1) +import Prim.Row as Row +import Prim.RowList (kind RowList, class RowToList, Cons, Nil) +import Record (delete, get, insert) +import Type.Row (RLProxy(..)) -- | An event handler, which receives a `SyntheticEvent` and performs some -- | effects in return. -type EventHandler = EffFn1 (react :: ReactFX) SyntheticEvent Unit +type EventHandler = EffectFn1 SyntheticEvent Unit -- | Event data that we receive from React. foreign import data SyntheticEvent :: Type @@ -59,8 +60,8 @@ derive newtype instance categoryBuilder :: Category EventFn -- | \value -> setState \_ -> { value } -- | } -- | ``` -handler :: forall a. EventFn SyntheticEvent a -> (a -> Eff (react :: ReactFX) Unit) -> EventHandler -handler (EventFn fn) cb = mkEffFn1 $ fn >>> cb +handler :: forall a. EventFn SyntheticEvent a -> (a -> Effect Unit) -> EventHandler +handler (EventFn fn) cb = mkEffectFn1 $ fn >>> cb -- | Create an `EventHandler` which discards the `SyntheticEvent`. -- | @@ -70,11 +71,11 @@ handler (EventFn fn) cb = mkEffFn1 $ fn >>> cb -- | input { onChange: handler_ (setState \_ -> { value }) -- | } -- | ``` -handler_ :: Eff (react :: ReactFX) Unit -> EventHandler -handler_ = mkEffFn1 <<< const +handler_ :: Effect Unit -> EventHandler +handler_ = mkEffectFn1 <<< const syntheticEvent :: EventFn SyntheticEvent SyntheticEvent -syntheticEvent = id +syntheticEvent = identity class Merge (rl :: RowList) fns a r | rl -> fns, rl a -> r where mergeImpl :: RLProxy rl -> Record fns -> EventFn a (Record r) @@ -84,10 +85,10 @@ instance mergeNil :: Merge Nil () a () where instance mergeCons :: ( IsSymbol l - , RowCons l (EventFn a b) fns_rest fns - , RowCons l b r_rest r - , RowLacks l fns_rest - , RowLacks l r_rest + , Row.Cons l (EventFn a b) fns_rest fns + , Row.Cons l b r_rest r + , Row.Lacks l fns_rest + , Row.Lacks l r_rest , Merge rest fns_rest a r_rest ) => Merge (Cons l (EventFn a b) rest) fns a r