Skip to content

jundl77/html-haskell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html-haskell

A simple, light-weight server that transpiles Haskell code to HTML.

This project arose from the need to build React components using Haskell. Under the hood, html-haskell uses type-of-html. Look at type-of-html to see what Haskell code you can write and how it is transformed to HTML.

Example:

Haskell code:

render = div_ $ colorPp "red" (genString "Hello")

colorPp color content = p_A (A.style_ $ "color: " ++ color) content

genString :: String -> String
genString str = str ++ " " ++ str ++ "!"

Resulting HTML:

<div>
  <p style="color: red">Hello Hello!</p>
</div>

API

/transpile

Make a POST request to /transpile with the following payload as JSON:

{
  code: "code to transpile"
}

Important: The code has to be formatted as shown in the example above, providing the render function that returns a Haskell-HTML.

/status

You can check the status of the service with a simple GET request to /status. If everything is okay, 200 should be returned.

Docker

You can find this server as a docker image under julianbrendl/html-haskell.

About

A REST API to convert haskell to HTML.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published