pretty-sop-0.2.0.0: A generic pretty-printer using generics-sop

Safe HaskellNone
LanguageHaskell2010

Generics.SOP.PrettyVal

Contents

Description

Generic pretty-printer.

This module defines a generic function that helps in defining class instances for the PrettyVal class from the pretty-show package.

Synopsis

Documentation

gprettyVal :: forall a. (Generic a, HasDatatypeInfo a, All2 PrettyVal (Code a)) => a -> Value Source

Generic pretty-printer.

This function turns a value into the uniform representation of type Value that is provided by the pretty-show package. The function has the suitable type to serve as the default implementation of the prettyVal function in the PrettyVal class.

If you have a datatype T that is an instance of generic-sop's Generic and HasDatatypeInfo classes, you can use gprettyVal as follows:

instance PrettyVal T where
  prettyVal = gprettyVal

Re-exports

class PrettyVal a where

A class for types that may be reified into a value. Instances of this class may be derived automatically, for datatypes that support Generics.

Minimal complete definition

Nothing

Methods

prettyVal :: a -> Value