[commit: ghc] wip/nfs-locking: Provide more useful ToPredicate instances (db56cf4)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 01:23:24 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/db56cf4eaf15378c3023de4e66a1285376eb6599/ghc

>---------------------------------------------------------------

commit db56cf4eaf15378c3023de4e66a1285376eb6599
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Mon Aug 14 23:07:05 2017 +0100

    Provide more useful ToPredicate instances


>---------------------------------------------------------------

db56cf4eaf15378c3023de4e66a1285376eb6599
 src/Hadrian/Expression.hs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Hadrian/Expression.hs b/src/Hadrian/Expression.hs
index dad9d32..b781cdd 100644
--- a/src/Hadrian/Expression.hs
+++ b/src/Hadrian/Expression.hs
@@ -75,14 +75,14 @@ p ? e = do
     bool <- toPredicate p
     if bool then e else mempty
 
-instance (c ~ c', b ~ b') => ToPredicate (Predicate c b) c' b' where
-    toPredicate = id
-
 instance ToPredicate Bool c b where
     toPredicate = pure
 
-instance ToPredicate (Action Bool) c b where
-    toPredicate = expr
+instance ToPredicate p c b => ToPredicate (Action p) c b where
+    toPredicate = toPredicate . expr
+
+instance (c ~ c', b ~ b', ToPredicate p c' b') => ToPredicate (Expr c b p) c' b' where
+    toPredicate p = toPredicate =<< p
 
 -- | Interpret a given expression according to the given 'Target'.
 interpret :: Target c b -> Expr c b a -> Action a



More information about the ghc-commits mailing list