packages feed

servant-elm 0.1.0.1 → 0.1.0.2

raw patch · 5 files changed

+45/−9 lines, 5 files

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+0.1.0.2+-------+* Fix for API endpoints that return Unit (kantp)+ 0.1.0.1 ------- * Convenience re-exports from Elm and Data.Proxy.
README.md view
@@ -6,20 +6,48 @@  Elm type generation coutesy of [krisajenkins/elm-export](https://github.com/krisajenkins/elm-export). +## Installation++Until `elm-export` and `servant >= 0.5` are released, `servant-elm` requires+stack. Add this to your `stack.yaml` file:++```yaml+...+packages:+  ...+- location:+    git: https://github.com/haskell-servant/servant.git+    commit: 761443fffecbe83aa408d5f705dd0a8dade08af9+  subdirs:+  - servant+  - servant-foreign+  - servant-server+  extra-dep: True+- location:+    git: https://www.github.com/mattjbray/elm-export+    commit: a8a5b61798fbb04e081f5c83cab76ceaabc5ba13+  extra-dep: True+- location:+    git: https://www.github.com/mattjbray/servant-elm+    commit: 749e09ed9d623284b3b90d1ae1ccba7ae79ad381+  extra-dep: True+...+```+ ## Example -Let's get some boring language pragmas and imports out of the way.+Let's get some language pragmas and imports out of the way.  ```haskell-{-# LANGUAGE DeriveGeneric     #-}-{-# LANGUAGE DataKinds         #-}-{-# LANGUAGE TypeOperators     #-}+{-# LANGUAGE DataKinds     #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE TypeOperators #-} -import           Data.Proxy   (Proxy(Proxy))-import           Elm          (Spec(Spec), ToElmType, specsToDir) import           GHC.Generics (Generic) import           Servant.API  ((:>), Capture, Get, JSON)-import           Servant.Elm  (defElmImports, generateElmForAPI)+import           Servant.Elm  (Proxy (Proxy), Spec (Spec), ToElmType,+                               defElmImports, generateElmForAPI, specsToDir,+                               specsToDir) ```  We have some Haskell-defined types and our Servant API.@@ -121,5 +149,6 @@  Other: +* Encode captures and query params? * Option to not use elm-export: generate functions that take a decoder and   String arguments.
servant-elm.cabal view
@@ -1,5 +1,5 @@ name:                servant-elm-version:             0.1.0.1+version:             0.1.0.2 synopsis:            Automatically derive Elm functions to query servant webservices. description:         Please see README.md homepage:            http://github.com/mattjbray/servant-elm#readme
src/Servant/Elm/Client.hs view
@@ -156,4 +156,4 @@ completeRequest method =   setHttpMethod method   . addFnSignature "()"-  . setDecoder "(succeed ())"+  . setDecoder "(Json.Decode.succeed ())"
test/Spec.hs view
@@ -29,6 +29,7 @@                        :> QueryParam "sort" String                        :> QueryParams "filters" (Maybe Bool)                        :> Get '[JSON] [Book]+          :<|> "nothing" :> Get '[JSON] ()  main :: IO () main = hspec $@@ -40,6 +41,7 @@       decodeBookSource <- readFile "test/decodeBookSource.elm"       getBooksBySource <- readFile "test/getBooksBySource.elm"       getBooksSource   <- readFile "test/getBooksSource.elm"+      getNothingSource <- readFile "test/getNothingSource.elm"       let generated = map (++ "\n") (generateElmForAPI (Proxy :: Proxy TestApi))           expected  = [ getOneSource                       , postTwoSource@@ -47,6 +49,7 @@                       , decodeBookSource                       , getBooksBySource                       , getBooksSource+                      , getNothingSource                       ]       generated `itemsShouldBe` expected