Debian Codegraph @

src/TextShow/Debug/Trace/Generic.hs

raw
1 {-# LANGUAGE FlexibleContexts #-}
2
3 {-|
4 Module: TextShow.Debug.Trace.Generic
5 Copyright: (C) 2014-2017 Ryan Scott
6 License: BSD-style (see the file LICENSE)
7 Maintainer: Ryan Scott
8 Stability: Provisional
9 Portability: GHC
10
11 Functions that trace the values of 'Generic' instances (even if they are not
12 instances of @TextShow@).
13
14 /Since: 2/
15 -}
16 module TextShow.Debug.Trace.Generic (
17 genericTraceTextShow
18 , genericTraceTextShowId
19 , genericTraceTextShowM
20 ) where
21
22 import GHC.Generics (Generic, Rep)
23
24 import Prelude ()
25 import Prelude.Compat
26
27 import TextShow.Debug.Trace
28 import TextShow.Generic (GTextShowT, genericShowt)
29
30 -- | A 'Generic' implementation of 'traceTextShow'.
31 --
32 -- /Since: 2/
33 genericTraceTextShow :: (Generic a, GTextShowT (Rep a ())) => a -> b -> b
34 genericTraceTextShow = tracet . genericShowt
35
36 -- | A 'Generic' implementation of 'traceTextShowId'.
37 --
38 -- /Since: 2/
39 genericTraceTextShowId :: (Generic a, GTextShowT (Rep a ())) => a -> a
40 genericTraceTextShowId a = tracet (genericShowt a) a
41
42 -- | A 'Generic' implementation of 'traceShowM'.
43 --
44 -- /Since: 2/
45 genericTraceTextShowM :: (Generic a, GTextShowT (Rep a ()), Applicative f) => a -> f ()
46 genericTraceTextShowM = tracetM . genericShowt