From 15a0022152795727edae0e58ddf078a1969cd314 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 8 Jul 2016 14:04:16 -0400 Subject: [PATCH] The contrasting function must be polymorphic. --- src/Term.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Term.hs b/src/Term.hs index 08378d2e2..8aa956f91 100644 --- a/src/Term.hs +++ b/src/Term.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, TypeSynonymInstances #-} +{-# LANGUAGE RankNTypes, TypeFamilies, TypeSynonymInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Term where @@ -37,7 +37,7 @@ termSize :: Term a annotation -> Integer termSize = cata size where size (_ :< syntax) = 1 + sum syntax -alignCofreeWith :: Functor f => (f (Cofree f a1) -> f (Cofree f a2) -> Maybe (f (These (Cofree f a1) (Cofree f a2)))) -> These (Cofree f a1) (Cofree f a2) -> Free (CofreeF f (These a1 a2)) (These (Cofree f a1) (Cofree f a2)) +alignCofreeWith :: Functor f => (forall a b. f a -> f b -> Maybe (f (These a b))) -> These (Cofree f a1) (Cofree f a2) -> Free (CofreeF f (These a1 a2)) (These (Cofree f a1) (Cofree f a2)) alignCofreeWith contrast terms = fromMaybe (pure terms) $ case terms of These t1 t2 -> let (a1 :< s1, a2 :< s2) = (runCofree t1, runCofree t2) in wrap . (These a1 a2 :<) . fmap (alignCofreeWith contrast) <$> contrast s1 s2