forked from mattjbray/servant-elm-example-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
34 lines (28 loc) · 1.12 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Data.Proxy (Proxy (Proxy))
import Elm (Spec (Spec), specsToDir, toElmTypeSource,
toElmDecoderSource, toElmEncoderSource)
import Servant.Elm (ElmOptions (..), defElmImports, defElmOptions,
generateElmForAPIWith, UrlPrefix (Static))
import Api.Types (Api, Author, Book)
elmOpts :: ElmOptions
elmOpts =
defElmOptions
{ urlPrefix = Static "http://localhost:8000/api" }
specs :: [Spec]
specs =
[ Spec ["Generated", "Api"]
(defElmImports
: toElmTypeSource (Proxy :: Proxy Author)
: toElmDecoderSource (Proxy :: Proxy Author)
: toElmEncoderSource (Proxy :: Proxy Author)
: toElmTypeSource (Proxy :: Proxy Book)
: toElmDecoderSource (Proxy :: Proxy Book)
: toElmEncoderSource (Proxy :: Proxy Book)
: generateElmForAPIWith elmOpts (Proxy :: Proxy Api))
]
main :: IO ()
main = specsToDir specs "frontend/src"