module Util.Default
( permute2Def , permute3Def
, Default (..)
) where
import Control.Applicative.Permutations (runPermutation, toPermutationWithDefault)
import Data.Default (Default, def)
permute2Def :: (Default a, Default b, Monad f, Alternative f) => f a -> f b -> f (a,b)
permute2Def :: f a -> f b -> f (a, b)
permute2Def a :: f a
a b :: f b
b = Permutation f (a, b) -> f (a, b)
forall (m :: * -> *) a.
(Alternative m, Monad m) =>
Permutation m a -> m a
runPermutation (Permutation f (a, b) -> f (a, b))
-> Permutation f (a, b) -> f (a, b)
forall a b. (a -> b) -> a -> b
$
(,) (a -> b -> (a, b))
-> Permutation f a -> Permutation f (b -> (a, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a -> Permutation f a
forall (m :: * -> *) a.
Alternative m =>
a -> m a -> Permutation m a
toPermutationWithDefault a
forall a. Default a => a
def f a
a
Permutation f (b -> (a, b))
-> Permutation f b -> Permutation f (a, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f b -> Permutation f b
forall (m :: * -> *) a.
Alternative m =>
a -> m a -> Permutation m a
toPermutationWithDefault b
forall a. Default a => a
def f b
b
permute3Def :: (Default a, Default b, Default c, Monad f, Alternative f) =>
f a -> f b -> f c -> f (a,b,c)
permute3Def :: f a -> f b -> f c -> f (a, b, c)
permute3Def a :: f a
a b :: f b
b c :: f c
c = Permutation f (a, b, c) -> f (a, b, c)
forall (m :: * -> *) a.
(Alternative m, Monad m) =>
Permutation m a -> m a
runPermutation (Permutation f (a, b, c) -> f (a, b, c))
-> Permutation f (a, b, c) -> f (a, b, c)
forall a b. (a -> b) -> a -> b
$
(,,) (a -> b -> c -> (a, b, c))
-> Permutation f a -> Permutation f (b -> c -> (a, b, c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a -> Permutation f a
forall (m :: * -> *) a.
Alternative m =>
a -> m a -> Permutation m a
toPermutationWithDefault a
forall a. Default a => a
def f a
a
Permutation f (b -> c -> (a, b, c))
-> Permutation f b -> Permutation f (c -> (a, b, c))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f b -> Permutation f b
forall (m :: * -> *) a.
Alternative m =>
a -> m a -> Permutation m a
toPermutationWithDefault b
forall a. Default a => a
def f b
b
Permutation f (c -> (a, b, c))
-> Permutation f c -> Permutation f (a, b, c)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> c -> f c -> Permutation f c
forall (m :: * -> *) a.
Alternative m =>
a -> m a -> Permutation m a
toPermutationWithDefault c
forall a. Default a => a
def f c
c