1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Define lifted showing for Both.

This commit is contained in:
Rob Rix 2017-09-10 19:32:25 +01:00
parent 4490297bb5
commit 62a6235161

View File

@ -7,6 +7,7 @@ module Data.Functor.Both
, snd , snd
, module X , module X
, liftShowsPrecBoth , liftShowsPrecBoth
, liftShowListBoth
) where ) where
import Data.Bifunctor.Join as X import Data.Bifunctor.Join as X
@ -14,6 +15,7 @@ import Data.Functor.Classes
import Data.Semigroup import Data.Semigroup
import Prelude hiding (fst, snd) import Prelude hiding (fst, snd)
import qualified Prelude import qualified Prelude
import Text.Show
-- | A computation over both sides of a pair. -- | A computation over both sides of a pair.
type Both a = Join (,) a type Both a = Join (,) a
@ -44,3 +46,6 @@ instance (Semigroup a) => Semigroup (Join (,) a) where
liftShowsPrecBoth :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Both a -> ShowS liftShowsPrecBoth :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Both a -> ShowS
liftShowsPrecBoth sp sl d = showsUnaryWith (liftShowsPrec2 sp sl sp sl) "Join" d . runJoin liftShowsPrecBoth sp sl d = showsUnaryWith (liftShowsPrec2 sp sl sp sl) "Join" d . runJoin
liftShowListBoth :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Both a] -> ShowS
liftShowListBoth sp sl = showListWith (liftShowsPrecBoth sp sl 0)