doc/tutorial/tutorial.cabal+1−1
@@ -1,5 +1,5 @@
11name: tutorial
2−version: 0.6
2+version: 0.6.1
33synopsis: The servant tutorial
44homepage: http://haskell-servant.github.io/
55license: BSD3
servant-blaze/servant-blaze.cabal+1−1
@@ -2,7 +2,7 @@
22-- documentation, see http://haskell.org/cabal/users-guide/
33
44name: servant-blaze
5−version: 0.6
5+version: 0.6.1
66synopsis: Blaze-html support for servant
77-- description:
88homepage: http://haskell-servant.github.io/
servant-cassava/servant-cassava.cabal+1−1
@@ -2,7 +2,7 @@
22-- documentation, see http://haskell.org/cabal/users-guide/
33
44name: servant-cassava
5−version: 0.6
5+version: 0.6.1
66synopsis: Servant CSV content-type for cassava
77-- description:
88homepage: http://haskell-servant.github.io/
servant-client/servant-client.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-client
2−version: 0.6
2+version: 0.6.1
33synopsis: automatical derivation of querying functions for servant webservices
44description:
55 This library lets you derive automatically Haskell functions that
servant-docs/servant-docs.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-docs
2−version: 0.6
2+version: 0.6.1
33synopsis: generate API docs for your servant webservice
44description:
55 Library for generating API docs from a servant API definition.
servant-foreign/servant-foreign.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-foreign
2−version: 0.6
2+version: 0.6.1
33synopsis: Helpers for generating clients for servant APIs in any programming language
44description:
55 Helper types and functions for generating client functions for servant APIs in any programming language
servant-js/servant-js.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-js
2−version: 0.6
2+version: 0.6.1
33synopsis: Automatically derive javascript functions to query servant webservices.
44description:
55 Automatically derive javascript functions to query servant webservices.
servant-lucid/servant-lucid.cabal+1−1
@@ -2,7 +2,7 @@
22-- documentation, see http://haskell.org/cabal/users-guide/
33
44name: servant-lucid
5−version: 0.6
5+version: 0.6.1
66synopsis: Servant support for lucid
77-- description:
88homepage: http://haskell-servant.github.io/
servant-mock/servant-mock.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-mock
2−version: 0.6
2+version: 0.6.1
33synopsis: Derive a mock server for free from your servant API types
44description:
55 Derive a mock server for free from your servant API types
servant-server/servant-server.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-server
2−version: 0.6
2+version: 0.6.1
33synopsis: A family of combinators for defining webservices APIs and serving them
44description:
55 A family of combinators for defining webservices APIs and serving them
servant/servant.cabal+2−1
@@ -1,5 +1,5 @@
11name: servant
2−version: 0.6
2+version: 0.6.1
33synopsis: A family of combinators for defining webservices APIs
44description:
55 A family of combinators for defining webservices APIs and serving them
@@ -96,6 +96,7 @@ test-suite spec
9696 Servant.API.ContentTypesSpec
9797 Servant.API.ResponseHeadersSpec
9898 Servant.Utils.LinksSpec
99+ Servant.Utils.MapSpec
99100 build-depends:
100101 base == 4.*
101102 , aeson
servant/src/Servant/Utils/Map.hsnew file+20
@@ -0,0 +1,20 @@
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE MultiParamTypeClasses #-}
3+{-# LANGUAGE RankNTypes #-}
4+{-# LANGUAGE TypeFamilies #-}
5+{-# LANGUAGE TypeOperators #-}
6+module Servant.Utils.Map (mapLeaves) where
7+
8+import Servant.API
9+
10+class Mappable s t a b where
11+ mapLeaves :: (forall x . a x -> b x) -> s -> t
12+
13+instance Mappable (a x) (b x) a b where
14+ mapLeaves f a = f a
15+
16+instance Mappable s t a b => Mappable (arg -> s) (arg -> t) a b where
17+ mapLeaves f s = mapLeaves f $ s
18+
19+instance (Mappable left left' a b, Mappable right right' a b) => Mappable (left :<|> right) (left' :<|> right') a b where
20+ mapLeaves f (left :<|> right) = mapLeaves f left :<|> mapLeaves f right
servant/test/Servant/Utils/MapSpec.hsnew file+27
@@ -0,0 +1,27 @@
1+module Servant.Utils.MapSpec where
2+
3+import Test.Hspec
4+
5+import Data.Functor.Identity
6+import Servant.API
7+import Servant.Utils.Map
8+spec :: Spec
9+spec = describe "Map" $ do
10+ it "maps " $ do
11+ let foo :: Bool -> Int -> String
12+ foo _ b = show b
13+
14+ bar :: () -> String -> Int -> Double
15+ bar _ _ i = fromIntegral i
16+
17+ foobar = foo :<|> bar
18+
19+ convert :: (Int -> a) -> Identity a
20+ convert f = Identity $ f 42
21+
22+ foo' :: Bool -> Identity String
23+ bar' :: () -> String -> Identity Double
24+ foo' :<|> bar' = mapLeaves convert foobar
25+
26+ foo' True `shouldBe` Identity "42"
27+ bar' () "" `shouldBe` Identity (42 :: Double)
sources.txt+2−2
@@ -1,10 +1,10 @@
11servant
2−servant-cassava
2+servant-server
33servant-client
4+servant-cassava
45servant-docs
56servant-foreign
67servant-js
7−servant-server
88servant-blaze
99servant-lucid
1010servant-mock