mirror of
https://github.com/github/semantic.git
synced 2024-12-23 14:54:16 +03:00
Define generic implementations for Show1.
This commit is contained in:
parent
467c808616
commit
d9abc56818
@ -1,5 +1,7 @@
|
|||||||
module Data.Functor.Classes.Show.Generic
|
module Data.Functor.Classes.Show.Generic
|
||||||
( Show1(..)
|
( Show1(..)
|
||||||
|
, genericLiftShowsPrec
|
||||||
|
, genericLiftShowList
|
||||||
, gliftShowsPrec
|
, gliftShowsPrec
|
||||||
, gliftShowList
|
, gliftShowList
|
||||||
) where
|
) where
|
||||||
@ -17,3 +19,11 @@ class GShow1 f where
|
|||||||
-- | showList function for an application of the type constructor based on showsPrec and showList functions for the argument type. The default implementation using standard list syntax is correct for most types.
|
-- | showList function for an application of the type constructor based on showsPrec and showList functions for the argument type. The default implementation using standard list syntax is correct for most types.
|
||||||
gliftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS
|
gliftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS
|
||||||
gliftShowList sp sl = showListWith (gliftShowsPrec sp sl 0)
|
gliftShowList sp sl = showListWith (gliftShowsPrec sp sl 0)
|
||||||
|
|
||||||
|
-- | A suitable implementation of Show1’s liftShowsPrec for Generic1 types.
|
||||||
|
genericLiftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
|
||||||
|
genericLiftShowsPrec sp sl d = gliftShowsPrec sp sl d . from1
|
||||||
|
|
||||||
|
-- | A suitable implementation of Show1’s liftShowsPrec for Generic1 types.
|
||||||
|
genericLiftShowList :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS
|
||||||
|
genericLiftShowList sp sl = gliftShowList sp sl . map from1
|
||||||
|
Loading…
Reference in New Issue
Block a user