From 8ee50727bde4779ba5c3aa98f74e669ada66bb26 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Wed, 17 Feb 2016 18:13:10 +0100 Subject: 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. --- tests/Test/StarWars/Data.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/Test/StarWars/Data.hs') 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 -- cgit v1.2.3