Skip to content

Latest commit

 

History

History
69 lines (43 loc) · 1.74 KB

README.md

File metadata and controls

69 lines (43 loc) · 1.74 KB

React-Haskell Hackage

As crazy as it seems, using React and Haskell together just may be a good idea.

I was driven to create this thing because I had a large existing Haskell codebase I wanted to put online. However, even without existing code, I think a lot of problems are better modeled in Haskell than JavaScript or other languages. Or you might want to use some existing Haskell libraries.

Examples

Let's put a simple paragraph on the page:

sample :: React () ()
sample = p_ [ class_ "style" ] $ em_ "andy warhol"

main :: IO ()
main = do
    Just elem <- elemById "id"
    render elem sample

That creates a dom node on the page that looks like:

<p class="style">
    <em>andy warhol</em>
</p>

We can make that a little more complicated with some more child nodes.

sample :: React () ()
sample = div_ [ class_ "beautify" ] $ do
    "velvet underground"

    input_

    "lou reed"

But of course that input doesn't do anything. Let's change that.

sample :: JSString -> React AppKey ()
sample str = div_ $ do
    "favorite artist:"

    input_ [ onChange (Just . targetValue) ]

    text str

Getting Started

TODO

Notes

Jordan Walke sketched out a similar API for OCaml.

We should try to adhere to React's Virtual DOM Terminology when possible.

License

MIT License

Bitdeli Badge