@@ -90,20 +90,17 @@ import Text.Show (showListWith)
9090-------------------------------------------------------------------------------
9191
9292-- | Options that further configure how the functions in
93- -- "Data.Functor.Classes.Generic" should behave.
94- newtype Options = Options
95- { ghc8ShowBehavior :: Bool
96- -- ^ If 'True', a default 'Show1' implementation will show hash signs
97- -- (@#@) when showing unlifted types.
98- }
93+ -- "Data.Functor.Classes.Generic" should behave. Currently, the 'Options' have
94+ -- no effect (but this may change in the future).
95+ data Options = Options
9996
10097-- | Options that match the behavior of the installed version of GHC.
10198defaultOptions :: Options
102- defaultOptions = latestGHCOptions
99+ defaultOptions = Options
103100
104101-- | Options that match the behavior of the most recent GHC release.
105102latestGHCOptions :: Options
106- latestGHCOptions = Options { ghc8ShowBehavior = True }
103+ latestGHCOptions = Options
107104
108105-------------------------------------------------------------------------------
109106-- * Eq
@@ -696,73 +693,71 @@ showsPrecDefault :: (GShow (Rep1 f a), Generic1 f)
696693 => Int -> f a -> ShowS
697694showsPrecDefault = showsPrecOptions defaultOptions
698695
699- -- | Like 'showsPrecDefault', but with configurable 'Options'.
696+ -- | Like 'showsPrecDefault', but with configurable 'Options'. Currently, the
697+ -- 'Options' have no effect (but this may change in the future).
700698showsPrecOptions :: (GShow (Rep1 f a ), Generic1 f )
701699 => Options -> Int -> f a -> ShowS
702- showsPrecOptions opts p = gshowsPrec opts p . from1
700+ showsPrecOptions _ p = gshowsPrec p . from1
703701
704702-- | Class of generic representation types that can be converted to a 'String'.
705703class GShow a where
706- gshowsPrec :: Options -> Int -> a -> ShowS
704+ gshowsPrec :: Int -> a -> ShowS
707705
708706instance GShow (f p ) => GShow (D1 d f p ) where
709- gshowsPrec opts p (M1 x) = gshowsPrec opts p x
707+ gshowsPrec p (M1 x) = gshowsPrec p x
710708
711709instance GShow (V1 p ) where
712- gshowsPrec _ = v1ShowsPrec
710+ gshowsPrec = v1ShowsPrec
713711
714712instance (GShow (f p ), GShow (g p )) => GShow ((f :+: g ) p ) where
715- gshowsPrec opts p (L1 x) = gshowsPrec opts p x
716- gshowsPrec opts p (R1 x) = gshowsPrec opts p x
713+ gshowsPrec p (L1 x) = gshowsPrec p x
714+ gshowsPrec p (R1 x) = gshowsPrec p x
717715
718716instance (Constructor c , GShowCon (f p ), IsNullaryCon f ) => GShow (C1 c f p ) where
719- gshowsPrec opts = c1ShowsPrec $ gshowsPrecCon opts
717+ gshowsPrec = c1ShowsPrec gshowsPrecCon
720718
721719-- | Class of generic representation types that can be converted to a 'String', and
722720-- for which the 'ConType' has been determined.
723721class GShowCon a where
724- gshowsPrecCon :: Options -> ConType -> Int -> a -> ShowS
722+ gshowsPrecCon :: ConType -> Int -> a -> ShowS
725723
726724instance GShowCon (U1 p ) where
727- gshowsPrecCon _ _ _ U1 = id
725+ gshowsPrecCon _ _ U1 = id
728726
729727instance Show c => GShowCon (K1 i c p ) where
730- gshowsPrecCon _ _ p (K1 x) = showsPrec p x
728+ gshowsPrecCon _ p (K1 x) = showsPrec p x
731729
732730instance (Selector s , GShowCon (f p )) => GShowCon (S1 s f p ) where
733- gshowsPrecCon opts = s1ShowsPrec . gshowsPrecCon opts
731+ gshowsPrecCon = s1ShowsPrec . gshowsPrecCon
734732
735733instance (GShowCon (f p ), GShowCon (g p )) => GShowCon ((f :*: g ) p ) where
736- gshowsPrecCon opts t =
737- productShowsPrec (gshowsPrecCon opts t)
738- (gshowsPrecCon opts t)
739- t
734+ gshowsPrecCon t = productShowsPrec (gshowsPrecCon t) (gshowsPrecCon t) t
740735
741736instance Show p => GShowCon (Par1 p ) where
742- gshowsPrecCon _ _ p (Par1 x) = showsPrec p x
737+ gshowsPrecCon _ p (Par1 x) = showsPrec p x
743738
744739instance (Show1 f , Show p ) => GShowCon (Rec1 f p ) where
745- gshowsPrecCon _ _ p (Rec1 x) = liftShowsPrec showsPrec showList p x
740+ gshowsPrecCon _ p (Rec1 x) = liftShowsPrec showsPrec showList p x
746741
747742instance (Show1 f , GShowCon (g p )) => GShowCon ((f :.: g ) p ) where
748- gshowsPrecCon opts t p (Comp1 x) =
749- let glspc = gshowsPrecCon opts t
743+ gshowsPrecCon t p (Comp1 x) =
744+ let glspc = gshowsPrecCon t
750745 in liftShowsPrec glspc (showListWith (glspc 0 )) p x
751746
752747instance GShowCon (UChar p ) where
753- gshowsPrecCon opts _ = uCharShowsPrec opts
748+ gshowsPrecCon _ = uCharShowsPrec
754749
755750instance GShowCon (UDouble p ) where
756- gshowsPrecCon opts _ = uDoubleShowsPrec opts
751+ gshowsPrecCon _ = uDoubleShowsPrec
757752
758753instance GShowCon (UFloat p ) where
759- gshowsPrecCon opts _ = uFloatShowsPrec opts
754+ gshowsPrecCon _ = uFloatShowsPrec
760755
761756instance GShowCon (UInt p ) where
762- gshowsPrecCon opts _ = uIntShowsPrec opts
757+ gshowsPrecCon _ = uIntShowsPrec
763758
764759instance GShowCon (UWord p ) where
765- gshowsPrecCon opts _ = uWordShowsPrec opts
760+ gshowsPrecCon _ = uWordShowsPrec
766761
767762-------------------------------------------------------------------------------
768763-- * Show1
@@ -774,11 +769,12 @@ liftShowsPrecDefault :: (GShow1 (Rep1 f), Generic1 f)
774769 -> Int -> f a -> ShowS
775770liftShowsPrecDefault = liftShowsPrecOptions defaultOptions
776771
777- -- | Like 'liftShowsPrecDefault', but with configurable 'Options'.
772+ -- | Like 'liftShowsPrecDefault', but with configurable 'Options'. Currently,
773+ -- the 'Options' have no effect (but this may change in the future).
778774liftShowsPrecOptions :: (GShow1 (Rep1 f ), Generic1 f )
779775 => Options -> (Int -> a -> ShowS ) -> ([a ] -> ShowS )
780776 -> Int -> f a -> ShowS
781- liftShowsPrecOptions opts sp sl p = gliftShowsPrec opts sp sl p . from1
777+ liftShowsPrecOptions _ sp sl p = gliftShowsPrec sp sl p . from1
782778
783779-- | Class of generic representation types for unary type constructors that can
784780-- be converted to a 'String'.
@@ -787,24 +783,24 @@ class
787783 (forall a. Show a => GShow (f a)) =>
788784#endif
789785 GShow1 f where
790- gliftShowsPrec :: Options -> (Int -> a -> ShowS ) -> ([a ] -> ShowS )
786+ gliftShowsPrec :: (Int -> a -> ShowS ) -> ([a ] -> ShowS )
791787 -> Int -> f a -> ShowS
792788
793789instance GShow1 f => GShow1 (D1 d f ) where
794- gliftShowsPrec opts sp sl p (M1 x) = gliftShowsPrec opts sp sl p x
790+ gliftShowsPrec sp sl p (M1 x) = gliftShowsPrec sp sl p x
795791
796792instance GShow1 V1 where
797- gliftShowsPrec _ _ _ = v1ShowsPrec
793+ gliftShowsPrec _ _ = v1ShowsPrec
798794
799795v1ShowsPrec :: Int -> V1 p -> ShowS
800796v1ShowsPrec _ x = case x of {}
801797
802798instance (GShow1 f , GShow1 g ) => GShow1 (f :+: g ) where
803- gliftShowsPrec opts sp sl p (L1 x) = gliftShowsPrec opts sp sl p x
804- gliftShowsPrec opts sp sl p (R1 x) = gliftShowsPrec opts sp sl p x
799+ gliftShowsPrec sp sl p (L1 x) = gliftShowsPrec sp sl p x
800+ gliftShowsPrec sp sl p (R1 x) = gliftShowsPrec sp sl p x
805801
806802instance (Constructor c , GShow1Con f , IsNullaryCon f ) => GShow1 (C1 c f ) where
807- gliftShowsPrec opts sp sl = c1ShowsPrec $ \ t -> gliftShowsPrecCon opts t sp sl
803+ gliftShowsPrec sp sl = c1ShowsPrec $ \ t -> gliftShowsPrecCon t sp sl
808804
809805c1ShowsPrec :: (Constructor c , IsNullaryCon f )
810806 => (ConType -> Int -> f p -> ShowS ) -> Int -> C1 c f p -> ShowS
@@ -847,17 +843,17 @@ class
847843 (forall a. Show a => GShowCon (f a)) =>
848844#endif
849845 GShow1Con f where
850- gliftShowsPrecCon :: Options -> ConType -> (Int -> a -> ShowS ) -> ([a ] -> ShowS )
846+ gliftShowsPrecCon :: ConType -> (Int -> a -> ShowS ) -> ([a ] -> ShowS )
851847 -> Int -> f a -> ShowS
852848
853849instance GShow1Con U1 where
854- gliftShowsPrecCon _ _ _ _ _ U1 = id
850+ gliftShowsPrecCon _ _ _ _ U1 = id
855851
856852instance Show c => GShow1Con (K1 i c ) where
857- gliftShowsPrecCon _ _ _ _ p (K1 x) = showsPrec p x
853+ gliftShowsPrecCon _ _ _ p (K1 x) = showsPrec p x
858854
859855instance (Selector s , GShow1Con f ) => GShow1Con (S1 s f ) where
860- gliftShowsPrecCon opts t sp sl = s1ShowsPrec $ gliftShowsPrecCon opts t sp sl
856+ gliftShowsPrecCon t sp sl = s1ShowsPrec $ gliftShowsPrecCon t sp sl
861857
862858s1ShowsPrec :: Selector s => (Int -> f p -> ShowS ) -> Int -> S1 s f p -> ShowS
863859s1ShowsPrec sp p sel@ (M1 x)
@@ -876,9 +872,9 @@ s1ShowsPrec sp p sel@(M1 x)
876872 selectorName = selName sel
877873
878874instance (GShow1Con f , GShow1Con g ) => GShow1Con (f :*: g ) where
879- gliftShowsPrecCon opts t sp sl =
880- productShowsPrec (gliftShowsPrecCon opts t sp sl)
881- (gliftShowsPrecCon opts t sp sl)
875+ gliftShowsPrecCon t sp sl =
876+ productShowsPrec (gliftShowsPrecCon t sp sl)
877+ (gliftShowsPrecCon t sp sl)
882878 t
883879
884880productShowsPrec :: (Int -> f p -> ShowS ) -> (Int -> g p -> ShowS )
@@ -909,56 +905,49 @@ productShowsPrec spf spg t p (a :*: b) =
909905 else showChar ' `' . showString o . showChar ' `'
910906
911907instance GShow1Con Par1 where
912- gliftShowsPrecCon _ _ sp _ p (Par1 x) = sp p x
908+ gliftShowsPrecCon _ sp _ p (Par1 x) = sp p x
913909
914910instance Show1 f => GShow1Con (Rec1 f ) where
915- gliftShowsPrecCon _ _ sp sl p (Rec1 x) = liftShowsPrec sp sl p x
911+ gliftShowsPrecCon _ sp sl p (Rec1 x) = liftShowsPrec sp sl p x
916912
917913instance (Show1 f , GShow1Con g ) => GShow1Con (f :.: g ) where
918- gliftShowsPrecCon opts t sp sl p (Comp1 x) =
919- let glspc = gliftShowsPrecCon opts t sp sl
914+ gliftShowsPrecCon t sp sl p (Comp1 x) =
915+ let glspc = gliftShowsPrecCon t sp sl
920916 in liftShowsPrec glspc (showListWith (glspc 0 )) p x
921917
922918instance GShow1Con UChar where
923- gliftShowsPrecCon opts _ _ _ = uCharShowsPrec opts
919+ gliftShowsPrecCon _ _ _ = uCharShowsPrec
924920
925921instance GShow1Con UDouble where
926- gliftShowsPrecCon opts _ _ _ = uDoubleShowsPrec opts
922+ gliftShowsPrecCon _ _ _ = uDoubleShowsPrec
927923
928924instance GShow1Con UFloat where
929- gliftShowsPrecCon opts _ _ _ = uFloatShowsPrec opts
925+ gliftShowsPrecCon _ _ _ = uFloatShowsPrec
930926
931927instance GShow1Con UInt where
932- gliftShowsPrecCon opts _ _ _ = uIntShowsPrec opts
928+ gliftShowsPrecCon _ _ _ = uIntShowsPrec
933929
934930instance GShow1Con UWord where
935- gliftShowsPrecCon opts _ _ _ = uWordShowsPrec opts
931+ gliftShowsPrecCon _ _ _ = uWordShowsPrec
936932
937- uCharShowsPrec :: Options -> Int -> UChar p -> ShowS
938- uCharShowsPrec opts p (UChar c) =
939- showsPrec (hashPrec opts p) (C # c) . oneHash opts
933+ uCharShowsPrec :: Int -> UChar p -> ShowS
934+ uCharShowsPrec p (UChar c) = shows (C # c) . oneHash
940935
941- uDoubleShowsPrec :: Options -> Int -> UDouble p -> ShowS
942- uDoubleShowsPrec opts p (UDouble d) =
943- showsPrec (hashPrec opts p) (D # d) . twoHash opts
936+ uDoubleShowsPrec :: Int -> UDouble p -> ShowS
937+ uDoubleShowsPrec p (UDouble d) = shows (D # d) . twoHash
944938
945- uFloatShowsPrec :: Options -> Int -> UFloat p -> ShowS
946- uFloatShowsPrec opts p (UFloat f) =
947- showsPrec (hashPrec opts p) (F # f) . oneHash opts
939+ uFloatShowsPrec :: Int -> UFloat p -> ShowS
940+ uFloatShowsPrec p (UFloat f) = shows (F # f) . oneHash
948941
949- uIntShowsPrec :: Options -> Int -> UInt p -> ShowS
950- uIntShowsPrec opts p (UInt i) =
951- showsPrec (hashPrec opts p) (I # i) . oneHash opts
942+ uIntShowsPrec :: Int -> UInt p -> ShowS
943+ uIntShowsPrec p (UInt i) = shows (I # i) . oneHash
952944
953- uWordShowsPrec :: Options -> Int -> UWord p -> ShowS
954- uWordShowsPrec opts p (UWord w) =
955- showsPrec (hashPrec opts p) (W # w) . twoHash opts
945+ uWordShowsPrec :: Int -> UWord p -> ShowS
946+ uWordShowsPrec p (UWord w) = shows (W # w) . twoHash
956947
957- oneHash , twoHash :: Options -> ShowS
958- hashPrec :: Options -> Int -> Int
959- oneHash opts = if ghc8ShowBehavior opts then showChar ' #' else id
960- twoHash opts = if ghc8ShowBehavior opts then showString " ##" else id
961- hashPrec opts = if ghc8ShowBehavior opts then const 0 else id
948+ oneHash , twoHash :: ShowS
949+ oneHash = showChar ' #'
950+ twoHash = showString " ##"
962951
963952-------------------------------------------------------------------------------
964953-- * GenericFunctorClasses
0 commit comments