aboutsummaryrefslogtreecommitdiff
path: root/Types/Transfer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Types/Transfer.hs')
-rw-r--r--Types/Transfer.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Types/Transfer.hs b/Types/Transfer.hs
index ade8fc763..73952c56e 100644
--- a/Types/Transfer.hs
+++ b/Types/Transfer.hs
@@ -5,9 +5,12 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE FlexibleInstances #-}
+
module Types.Transfer where
import Types
+import Types.Remote (Verification(..))
import Utility.PID
import Utility.QuickCheck
@@ -66,3 +69,25 @@ instance Arbitrary TransferInfo where
-- associated file cannot be empty (but can be Nothing)
<*> (AssociatedFile <$> arbitrary `suchThat` (/= Just ""))
<*> arbitrary
+
+class Observable a where
+ observeBool :: a -> Bool
+ observeFailure :: a
+
+instance Observable Bool where
+ observeBool = id
+ observeFailure = False
+
+instance Observable (Bool, Verification) where
+ observeBool = fst
+ observeFailure = (False, UnVerified)
+
+instance Observable (Either e Bool) where
+ observeBool (Left _) = False
+ observeBool (Right b) = b
+ observeFailure = Right False
+
+instance Observable (Either e (Maybe a)) where
+ observeBool (Right (Just _)) = True
+ observeBool _ = False
+ observeFailure = Right Nothing