Skip to content

maks83/react-haskell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

React bindings for Haskell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 71.7%
  • JavaScript 17.4%
  • CSS 9.4%
  • Shell 1.5%