diff options
| author | Danny Navarro <j@dannynavarro.net> | 2016-02-17 18:13:10 +0100 |
|---|---|---|
| committer | Danny Navarro <j@dannynavarro.net> | 2016-02-18 13:49:02 +0100 |
| commit | 8ee50727bde4779ba5c3aa98f74e669ada66bb26 (patch) | |
| tree | 0e374dcb107443115030f6ba0826a8a5f0503771 /tests/Test/StarWars/Data.hs | |
| parent | a6b2fd297b01a4d7a9e4ea6fc73e21150c1259b9 (diff) | |
| download | graphql-8ee50727bde4779ba5c3aa98f74e669ada66bb26.tar.gz | |
Overhaul Schema DSL
Aside of making the definition of Schemas easier, it takes care of
issues like nested aliases which previously wasn't possible. The naming
of the DSL functions is still provisional.
Diffstat (limited to 'tests/Test/StarWars/Data.hs')
| -rw-r--r-- | tests/Test/StarWars/Data.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs index 2c1b323..a898cea 100644 --- a/tests/Test/StarWars/Data.hs +++ b/tests/Test/StarWars/Data.hs @@ -38,7 +38,7 @@ data Droid = Droid type Character = Either Droid Human --- I don't think this is cumbersome enough to make it worth using lens. +-- I still don't think this is cumbersome enough to bring lens id_ :: Character -> ID id_ (Left x) = _id_ . _droidChar $ x @@ -128,7 +128,6 @@ threepio = Droid artoo :: Character artoo = Left artoo' - artoo' :: Droid artoo' = Droid { _droidChar = CharCommon @@ -149,7 +148,6 @@ getHero _ = artoo getHeroIO :: Int -> IO Character getHeroIO = pure . getHero - getHuman :: Alternative f => ID -> f Character getHuman = fmap Right . getHuman' @@ -171,3 +169,9 @@ getDroid' _ = empty getFriends :: Character -> [Character] getFriends char = catMaybes $ liftA2 (<|>) getDroid getHuman <$> friends char + +getEpisode :: Alternative f => Int -> f Text +getEpisode 4 = pure "NEWHOPE" +getEpisode 5 = pure "EMPIRE" +getEpisode 6 = pure "JEDI" +getEpisode _ = empty |
