From 8d9562e94ee217a8f1d76f327b7c914fa738e598 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 5 Jan 2017 14:40:28 -0500 Subject: [PATCH] Define a lifting of cons3. --- src/Data/Functor/Listable.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Data/Functor/Listable.hs b/src/Data/Functor/Listable.hs index f847c8d11..e5dcc727f 100644 --- a/src/Data/Functor/Listable.hs +++ b/src/Data/Functor/Listable.hs @@ -14,6 +14,7 @@ module Data.Functor.Listable , tiers2 , liftCons1 , liftCons2 +, liftCons3 ) where import Prologue @@ -39,6 +40,10 @@ liftCons1 tiers f = mapT f tiers `addWeight` 1 liftCons2 :: [[a]] -> [[b]] -> (a -> b -> c) -> [[c]] liftCons2 tiers1 tiers2 f = mapT (uncurry f) (productWith (,) tiers1 tiers2) `addWeight` 1 +liftCons3 :: [[a]] -> [[b]] -> [[c]] -> (a -> b -> c -> d) -> [[d]] +liftCons3 tiers1 tiers2 tiers3 f = mapT (uncurry3 f) (productWith (\ x (y, z) -> (x, y, z)) tiers1 (liftCons2 tiers2 tiers3 (,)) ) `addWeight` 1 + where uncurry3 f (a, b, c) = f a b c + -- Instances