git.iko.soy/haskell-servant/servant-elm
on master help sign in
Moves polymorphic data to a separate module
0365af3=
servant-elm.cabal+1
@@ -48,6 +48,7 @@ test-suite servant-elm-test
48 hs-source-dirs: test
48 hs-source-dirs: test
49 main-is: GenerateSpec.hs
49 main-is: GenerateSpec.hs
50 other-modules: Common
50 other-modules: Common
51+ , PolymorphicData
51 build-depends:
52 build-depends:
52 Diff
53 Diff
53 , HUnit
54 , HUnit
test/Common.hs−8
@@ -15,15 +15,7 @@ data Book = Book
15 { title :: String
15 { title :: String
16 }
16 }
17
17
18−data PolymorphicData a b = PolymorphicData a b deriving (Show, Eq)
19−data SomeRecord = SomeRecord
20− { recordId :: Int
21− , recordName :: String
22− } deriving (Show, Eq)
23−
24deriveBoth defaultOptions ''Book
18deriveBoth defaultOptions ''Book
25−deriveBoth defaultOptions ''PolymorphicData
26−deriveBoth defaultOptions ''SomeRecord
27
19
28type TestApi =
20type TestApi =
29 "one"
21 "one"
test/GenerateSpec.hs+2−1
@@ -17,7 +17,8 @@ import Servant.Elm
17import Test.Hspec (Spec, describe, hspec, it)
17import Test.Hspec (Spec, describe, hspec, it)
18import Test.HUnit (Assertion, assertEqual)
18import Test.HUnit (Assertion, assertEqual)
19
19
20−import Common (testApi, SomeRecord(..), PolymorphicData(..))
20+import Common (testApi)
21+import PolymorphicData (SomeRecord(..), PolymorphicData(..))
21
22
22
23
23main :: IO ()
24main :: IO ()
test/PolymorphicData.hsnew file+15
@@ -0,0 +1,15 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+
3+module PolymorphicData where
4+
5+import Servant.Elm
6+
7+
8+data PolymorphicData a b = PolymorphicData a b deriving (Show, Eq)
9+data SomeRecord = SomeRecord
10+ { recordId :: Int
11+ , recordName :: String
12+ } deriving (Show, Eq)
13+
14+deriveBoth defaultOptions ''PolymorphicData
15+deriveBoth defaultOptions ''SomeRecord