Skip to content

Commit c0efb74

Browse files
committed
Updates for 0.7
1 parent b4f1156 commit c0efb74

File tree

25 files changed

+2471
-1124
lines changed

25 files changed

+2471
-1124
lines changed

Makefile

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,60 @@
11
purescript-react
22
================
33

4-
React Bindings for PureScript.
4+
[![Maintainer: paf31](https://img.shields.io/badge/maintainer-paf31-lightgrey.svg)](http://github.com/paf31)
55

6-
**WARNING:** This is alpha quaility software and you need to use [nightly build
7-
of React][nightly].
6+
Low-level React Bindings for PureScript.
87

9-
```haskell
8+
For a more high-level set of bindings, you might like to look at `purescript-thermite`.
9+
10+
- [Module Documentation](docs/)
11+
12+
## Building
13+
14+
The library and example can be built with Pulp as follows:
15+
16+
pulp dep update
17+
pulp build
18+
19+
pulp test -r cat > example/index.js
20+
open example/index.html
21+
22+
## Example
23+
24+
```purescript
1025
module Main where
1126
27+
import Prelude
28+
29+
import Control.Monad.Eff
30+
1231
import React
1332
import React.DOM
1433
1534
hello = mkUI spec do
1635
props <- getProps
17-
return $ h1 [
18-
className "Hello"
19-
] [
20-
text "Hello, ",
21-
text props.name
22-
]
36+
return $ h1 [ className "Hello"
37+
]
38+
[ text "Hello, "
39+
, text props.name
40+
]
2341
2442
incrementCounter = do
2543
val <- readState
2644
writeState (val + 1)
2745
28-
counter = mkUI spec { getInitialState = return 0 } do
46+
counter = mkUI (spec { getInitialState = return 0 }) do
2947
val <- readState
30-
return $ p [
31-
className "Counter",
32-
onClick incrementCounter
33-
] [
34-
text (show val),
35-
text " Click me to increment!"
36-
]
48+
return $ p [ className "Counter"
49+
, onClick incrementCounter
50+
]
51+
[ text (show val)
52+
, text " Click me to increment!"
53+
]
3754
3855
main = do
39-
let component = div [] [hello {name: "World"}, counter {}]
56+
let component = div [] [ hello { name: "World" }
57+
, counter {}
58+
]
4059
renderToBody component
4160
```
42-
43-
[nightly]: http://react.zpao.com/builds/master/latest/react.js

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"tests"
1717
],
1818
"devDependencies": {
19+
"purescript-console": "^0.1.0",
1920
"react": "~0.10.0"
2021
}
2122
}

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.js

example/app/index.html renamed to example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</style>
1212
</head>
1313
<body>
14-
<script src="bower_components/react/react.js"></script>
15-
<script src="app.js"></script>
14+
<script src="../bower_components/react/react.js"></script>
15+
<script src="index.js"></script>
1616
</body>
1717
</html>

example/tutorial/tutorial.purs

Lines changed: 0 additions & 109 deletions
This file was deleted.

gulpfile.js

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module Control.Monad.Eff.Class (MonadEff, liftEff) where
2+
import Prelude ()
3+
import Prim ()
4+
import Prelude ()
5+
import Control.Monad.Eff ()
6+
-- | The `MonadEff` class captures those monads which support native effects.
7+
-- |
8+
-- | Instances are provided for `Eff` itself, and the standard monad transformers.
9+
-- |
10+
-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action
11+
-- | of type `Eff eff a` into the monad.
12+
-- |
13+
-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be
14+
-- | tricky. It is generally recommended to either work with a polymorphic row of effects,
15+
-- | or a concrete, closed row of effects such as `(trace :: Trace)`.
16+
-- | The `MonadEff` class captures those monads which support native effects.
17+
-- |
18+
-- | Instances are provided for `Eff` itself, and the standard monad transformers.
19+
-- |
20+
-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action
21+
-- | of type `Eff eff a` into the monad.
22+
-- |
23+
-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be
24+
-- | tricky. It is generally recommended to either work with a polymorphic row of effects,
25+
-- | or a concrete, closed row of effects such as `(trace :: Trace)`.
26+
-- | The `MonadEff` class captures those monads which support native effects.
27+
-- |
28+
-- | Instances are provided for `Eff` itself, and the standard monad transformers.
29+
-- |
30+
-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action
31+
-- | of type `Eff eff a` into the monad.
32+
-- |
33+
-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be
34+
-- | tricky. It is generally recommended to either work with a polymorphic row of effects,
35+
-- | or a concrete, closed row of effects such as `(trace :: Trace)`.
36+
class (Prelude.Monad m) <= MonadEff eff m where
37+
liftEff :: forall a. Control.Monad.Eff.Eff eff a -> m a
38+
foreign import instance monadEffEff :: Control.Monad.Eff.Class.MonadEff eff (Control.Monad.Eff.Eff eff)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Control.Monad.Eff.Console (CONSOLE(), print, error, log) where
2+
import Prelude ()
3+
import Control.Monad.Eff.Console ()
4+
import Prim ()
5+
import Prelude ()
6+
import Control.Monad.Eff ()
7+
-- | The `CONSOLE` effect represents those computations which write to the console.
8+
-- | Write a message to the console.
9+
-- | Write an error to the console.
10+
-- | Write a value to the console, using its `Show` instance to produce a `String`.
11+
foreign import data CONSOLE :: !
12+
foreign import print :: forall a eff. (Prelude.Show a) => a -> Control.Monad.Eff.Eff (console :: Control.Monad.Eff.Console.CONSOLE | eff) Prelude.Unit
13+
foreign import error :: forall eff. Prim.String -> Control.Monad.Eff.Eff (console :: Control.Monad.Eff.Console.CONSOLE | eff) Prelude.Unit
14+
foreign import log :: forall eff. Prim.String -> Control.Monad.Eff.Eff (console :: Control.Monad.Eff.Console.CONSOLE | eff) Prelude.Unit
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Control.Monad.Eff.Unsafe (unsafeInterleaveEff) where
2+
import Prim ()
3+
import Prelude ()
4+
import Control.Monad.Eff ()
5+
-- | Change the type of an effectful computation, allowing it to be run in another context.
6+
-- |
7+
-- | Note: use of this function can result in arbitrary side-effects.
8+
foreign import unsafeInterleaveEff :: forall eff1 eff2 a. Control.Monad.Eff.Eff eff1 a -> Control.Monad.Eff.Eff eff2 a

0 commit comments

Comments
 (0)