Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- class GShow t where
- gshowsPrec :: Int -> t a -> ShowS
- defaultGshowsPrec :: Show (t a) => Int -> t a -> ShowS
- gshows :: GShow t => t a -> ShowS
- gshow :: GShow t => t a -> String
- class GRead t where
- greadsPrec :: Int -> GReadS t
- type GReadS t = String -> [(Some t, String)]
- greads :: GRead t => GReadS t
- gread :: GRead t => String -> (forall a. t a -> b) -> b
- greadMaybe :: GRead t => String -> (forall a. t a -> b) -> Maybe b
- getGReadResult :: Some tag -> (forall a. tag a -> b) -> b
- mkGReadResult :: tag a -> Some tag
Showing
Show
-like class for 1-type-parameter GADTs. GShow t => ...
is equivalent to something
like (forall a. Show (t a)) => ...
. The easiest way to create instances would probably be
to write (or derive) an instance Show (T a)
, and then simply say:
instance GShow t where gshowsPrec = defaultGshowsPrec
gshowsPrec :: Int -> t a -> ShowS Source #
Instances
GShow SNat Source # | |
Defined in Data.GADT.Internal | |
GShow SChar Source # | |
Defined in Data.GADT.Internal | |
GShow SSymbol Source # | |
Defined in Data.GADT.Internal | |
GShow (TypeRep :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
GShow ((:~:) a :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
GShow (GOrdering a :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
(GShow a, GShow b) => GShow (Product a b :: k -> Type) Source # |
|
Defined in Data.GADT.Internal | |
(GShow a, GShow b) => GShow (Sum a b :: k -> Type) Source # |
|
Defined in Data.GADT.Internal | |
GShow ((:~~:) a :: k -> Type) Source # | Since: 1.0.4 |
Defined in Data.GADT.Internal | |
(GShow a, GShow b) => GShow (a :*: b :: k -> Type) Source # |
Since: 1.0.4 |
Defined in Data.GADT.Internal | |
(GShow a, GShow b) => GShow (a :+: b :: k -> Type) Source # |
Since: 1.0.4 |
Defined in Data.GADT.Internal |
defaultGshowsPrec :: Show (t a) => Int -> t a -> ShowS Source #
If f
has a 'Show (f a)' instance, this function makes a suitable default
implementation of gshowsPrec
.
Since: 1.0.4
Reading
Read
-like class for 1-type-parameter GADTs. Unlike GShow
, this one cannot be
mechanically derived from a Read
instance because greadsPrec
must choose the phantom
type based on the String
being parsed.
greadsPrec :: Int -> GReadS t Source #
Instances
GRead ((:~:) a :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
GRead (GOrdering a :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
(GRead a, GRead b) => GRead (Sum a b :: k -> Type) Source # | |
Defined in Data.GADT.Internal | |
(GRead a, GRead b) => GRead (a :+: b :: k -> Type) Source # | Since: 1.0.4 |
Defined in Data.GADT.Internal | |
k1 ~ k2 => GRead ((:~~:) a :: k2 -> Type) Source # | Since: 1.0.4 |
Defined in Data.GADT.Internal |
type GReadS t = String -> [(Some t, String)] Source #
GReadS t
is equivalent to ReadS (forall b. (forall a. t a -> b) -> b)
, which is
in turn equivalent to ReadS (Exists t)
(with data Exists t where Exists :: t a -> Exists t
)
greadMaybe :: GRead t => String -> (forall a. t a -> b) -> Maybe b Source #
>>>
greadMaybe "InL Refl" mkSome :: Maybe (Some (Sum ((:~:) Int) ((:~:) Bool)))
Just (mkSome (InL Refl))
>>>
greadMaybe "L1 Refl" mkSome :: Maybe (Some ((:~:) Int :+: (:~:) Bool))
Just (mkSome (L1 Refl))
>>>
greadMaybe "garbage" mkSome :: Maybe (Some ((:~:) Int))
Nothing
getGReadResult :: Some tag -> (forall a. tag a -> b) -> b Source #
mkGReadResult :: tag a -> Some tag Source #