From 285ccb0af954059879b12e33754fd10ccbed646d Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Wed, 1 Mar 2017 22:04:13 -0300 Subject: Implement type instrospection tests The main intention with this commit is to show a poor's man way to support type instrospection. --- tests/Test/StarWars/Data.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/Test/StarWars/Data.hs') diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs index 17263c0..a710dd8 100644 --- a/tests/Test/StarWars/Data.hs +++ b/tests/Test/StarWars/Data.hs @@ -1,11 +1,7 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Test.StarWars.Data where -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>), pure) import Data.Monoid (mempty) -#endif import Control.Applicative (Alternative, (<|>), empty, liftA2) import Data.Maybe (catMaybes) @@ -38,8 +34,6 @@ data Droid = Droid type Character = Either Droid Human --- I still don't think this is cumbersome enough to bring lens - id_ :: Character -> ID id_ (Left x) = _id_ . _droidChar $ x id_ (Right x) = _id_ . _humanChar $ x @@ -59,6 +53,9 @@ appearsIn (Right x) = _appearsIn . _humanChar $ x secretBackstory :: Character -> Text secretBackstory = error "secretBackstory is secret." +typeName :: Character -> Text +typeName = either (const "Droid") (const "Human") + luke :: Character luke = Right luke' -- cgit v1.2.3