Copyright | (C) 2017 Ryan Scott |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Richard Eisenberg (rae@cs.brynmawr.edu) |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class ShowSing k where
The ShowSing
class
class ShowSing k where Source #
Members of the ShowSing
kind class can have their Sing
values
converted to String
s in a fashion similar to that of the Show
class.
(In fact, this class only exists because one cannot write Show
instances
for Sing
s of the form
instance (forall z. Show (Sing (z :: k))) => Show (Sing (x :: [k]))
.)
This class should not be confused with the promoted or singled versions of
Show
from Data.Singletons.Prelude.Show (PShow
and SShow
, respectively).
The output of ShowSing
is intended to reflect the singleton type, whereas
the output of PShow
and SShow
reflects the original type. That is, showing
SFalse
with ShowSing
would yield "SFalse"
, whereas PShow
and SShow
would yield "False"
.
Instances of this class are generated alongside singleton definitions for
datatypes that derive a Show
instance. Moreover, having a ShowSing
instances makes it simple to define a Show
instance. For instance:
instanceShowSing
a =>ShowSing
[a] whereshowsSingPrec
= ... instanceShowSing
a =>Show
(Sing
(x :: [a])) whereshowsPrec
=showsSingPrec
As a result, singleton definitions for datatypes that derive a Show
instance also get a Show
instance for the singleton type as well
(in addition to promoted and singled Show
instances).
To recap: singletons
will give you all of these for a datatype that derives
a Show
instance:
- A promoted (
PShow
) instance - A singled (
SShow
) instance - A
ShowSing
instance for the singleton type - A
Show
instance for the singleton type
What a bargain!
showsSingPrec :: Int -> Sing (a :: k) -> ShowS Source #
convert a showsSingPrec
p sSing
value p
to a readable String
with precedence p
.
Instances
Orphan instances
Show (SSymbol s) Source # | |
Show (SNat n) Source # | |
Show (Sing z) Source # | |
(ShowSing a, ShowSing [a]) => Show (Sing z) Source # | |
ShowSing a => Show (Sing z) Source # | |
Show (Sing z) Source # | |
(ShowSing a, ShowSing b) => Show (Sing z) Source # | |
Show (Sing z) Source # | |
(ShowSing a, ShowSing b) => Show (Sing z) Source # | |
(ShowSing a, ShowSing b, ShowSing c) => Show (Sing z) Source # | |
(ShowSing a, ShowSing b, ShowSing c, ShowSing d) => Show (Sing z) Source # | |
(ShowSing a, ShowSing b, ShowSing c, ShowSing d, ShowSing e) => Show (Sing z) Source # | |
(ShowSing a, ShowSing b, ShowSing c, ShowSing d, ShowSing e, ShowSing f) => Show (Sing z) Source # | |
(ShowSing a, ShowSing b, ShowSing c, ShowSing d, ShowSing e, ShowSing f, ShowSing g) => Show (Sing z) Source # | |
Show (Sing z) Source # | |
(ShowSing a, ShowSing [a]) => Show (Sing z) Source # | |