The elm-bridge package

[Tags:bsd3, library, test]

Building the bridge from Haskell to Elm and back. Define types once, use on both sides and enjoy easy (de)serialisation. Cheers! This module only supports Elm 0.18. Version 0.3.* supports both Elm 0.16 and Elm 0.17.

[Skip to Readme]


Versions,,,,,,, 0.4.0, 0.4.1
Change log
Dependencies aeson (>=0.9 && <1.2), base (>=4.7 && <5), template-haskell [details]
License BSD3
Copyright (c) 2015 - 2016 Alexander Thiemann and contributors
Author Alexander Thiemann <>, Simon Marechal <>
Maintainer Alexander Thiemann <>
Category Web, Compiler, Language
Home page
Source repository head: git clone
Uploaded Tue Jun 6 09:39:10 UTC 2017 by SimonMarechal
Updated Tue Jun 6 11:51:25 UTC 2017 by SimonMarechal to revision 1
Distributions LTSHaskell:0.4.1, NixOS:0.4.1, Stackage:0.4.1, Tumbleweed:0.4.0
Downloads 546 total (100 in the last 30 days)
1 []
Status Docs not available [build log]
All reported builds failed as of 2017-06-06 [all 3 reports]
Hackage Matrix CI


  • Elm
    • Elm.Derive
    • Elm.Json
    • Elm.Module
    • Elm.TyRender
    • Elm.TyRep
    • Elm.Versions


Maintainer's Corner

For package maintainers and hackage trustees

Readme for elm-bridge

Readme for elm-bridge-0.4.1

Elm Bridge

Build Status

Hackage Deps


Hackage: elm-bridge

Building the bridge from Haskell to Elm and back. Define types once, use on both sides and enjoy easy (de)serialisation. Cheers!

This version of the package only supports Elm 0.18. Version supports Elm 0.16 and Elm 0.17.

Note that the bartavelle/json-helpers package, with version >= 1.2.0, is expected by the generated Elm modules.


{-# LANGUAGE TemplateHaskell #-}
import Elm.Derive
import Elm.Module

import Data.Proxy

data Foo
   = Foo
   { f_name :: String
   , f_blablub :: Int
   } deriving (Show, Eq)

deriveBoth defaultOptions ''Foo

main :: IO ()
main =
    putStrLn $ makeElmModule "Foo"
    [ DefineElm (Proxy :: Proxy Foo)

Output will be:

module Foo where

import Json.Decode
import Json.Decode exposing ((:=))
import Json.Encode
import Json.Helpers exposing (..)

type alias Foo  =
   { f_name: String
   , f_blablub: Int

jsonDecFoo : Json.Decode.Decoder ( Foo )
jsonDecFoo =
   ("f_name" := Json.Decode.string) `Json.Decode.andThen` \pf_name ->
   ("f_blablub" := `Json.Decode.andThen` \pf_blablub ->
   Json.Decode.succeed {f_name = pf_name, f_blablub = pf_blablub}

jsonEncFoo : Foo -> Value
jsonEncFoo  val =
   [ ("f_name", Json.Encode.string val.f_name)
   , ("f_blablub", val.f_blablub)

For more usage examples check the tests or the examples dir.



  • Using cabal: cabal install elm-bridge
  • From Source: git clone && cd elm-bridge && cabal install


  • elm package install bartavelle/json-helpers


Pull requests are welcome! Please consider creating an issue beforehand, so we can discuss what you would like to do. Code should be written in a consistent style throughout the project. Avoid whitespace that is sensible to conflicts. (E.g. alignment of = signs in functions definitions) Note that by sending a pull request you agree that your contribution can be released under the BSD3 License as part of the elm-bridge package or related packages.