| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Cooked.Pretty.Class
Description
This module provides common functions to help implement pretty-printers in cooked-validators
Synopsis
- type DocCooked = Doc ()
 - class PrettyCooked a where
- prettyCookedOpt :: PrettyCookedOpts -> a -> DocCooked
 - prettyCooked :: a -> DocCooked
 
 - class PrettyCookedList a where
- prettyCookedOptList :: PrettyCookedOpts -> a -> [DocCooked]
 - prettyCookedOptListMaybe :: PrettyCookedOpts -> a -> [Maybe DocCooked]
 - prettyCookedList :: a -> [DocCooked]
 
 - class PrettyCookedMaybe a where
- prettyCookedOptMaybe :: PrettyCookedOpts -> a -> Maybe DocCooked
 - prettyCookedMaybe :: a -> Maybe DocCooked
 
 - printCookedOpt :: PrettyCooked a => PrettyCookedOpts -> a -> IO ()
 - printCooked :: PrettyCooked a => a -> IO ()
 - renderString :: (a -> DocCooked) -> a -> String
 - prettyHash :: ToHash a => PrettyCookedOpts -> a -> DocCooked
 - prettyItemize :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> DocCooked -> a -> DocCooked
 - prettyItemizeNoTitle :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> a -> DocCooked
 - prettyItemizeNonEmpty :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> DocCooked -> a -> Maybe DocCooked
 
Documentation
class PrettyCooked a where Source #
Type class of things that can be pretty printed as a single document. You
 need to implement either prettyCookedOpt or prettyCooked manually,
 otherwise calling either of them will resulting in a infinite loop.
Minimal complete definition
Nothing
Methods
prettyCookedOpt :: PrettyCookedOpts -> a -> DocCooked Source #
Pretty prints an element based on some PrettyCookedOpts
prettyCooked :: a -> DocCooked Source #
Pretty prints an element directly
Instances
class PrettyCookedList a where Source #
Type class of things that can be pretty printed as a list of
 documents. Similarly to PrettyCooked, at least of the functions from this
 class needs to be manually implemented to avoid infinite loops.
Minimal complete definition
Nothing
Methods
prettyCookedOptList :: PrettyCookedOpts -> a -> [DocCooked] Source #
Pretty prints an element as a list on some PrettyCookedOpts
prettyCookedOptListMaybe :: PrettyCookedOpts -> a -> [Maybe DocCooked] Source #
Pretty prints an element as a list of optional documents
prettyCookedList :: a -> [DocCooked] Source #
Pretty prints an elements as a list
Instances
class PrettyCookedMaybe a where Source #
Type class of things that can be optionally pretty printed as a document
Minimal complete definition
Nothing
Methods
prettyCookedOptMaybe :: PrettyCookedOpts -> a -> Maybe DocCooked Source #
Pretty prints an optional document on some PrettyCookedOpts
prettyCookedMaybe :: a -> Maybe DocCooked Source #
Pretty prints an option document
Instances
| PrettyCookedMaybe TxSkelOutDatum Source # | Prints a   | 
Defined in Cooked.Pretty.Skeleton Methods prettyCookedOptMaybe :: PrettyCookedOpts -> TxSkelOutDatum -> Maybe DocCooked Source # prettyCookedMaybe :: TxSkelOutDatum -> Maybe DocCooked Source #  | |
| PrettyCookedMaybe (Maybe DocCooked) Source # | |
Defined in Cooked.Pretty.Class Methods prettyCookedOptMaybe :: PrettyCookedOpts -> Maybe DocCooked -> Maybe DocCooked Source # prettyCookedMaybe :: Maybe DocCooked -> Maybe DocCooked Source #  | |
printCookedOpt :: PrettyCooked a => PrettyCookedOpts -> a -> IO () Source #
Use this in the REPL as an alternative to the default print function when
 dealing with pretty-printable cooked values.
For example, printCookedOpt def runMockChain i0 foo
printCooked :: PrettyCooked a => a -> IO () Source #
Version of printCookedOpt that uses default pretty printing options.
renderString :: (a -> DocCooked) -> a -> String Source #
Use this to convert a pretty-printer to a regular show function using default layout options. This is used in Testing because Tasty uses strings.
prettyHash :: ToHash a => PrettyCookedOpts -> a -> DocCooked Source #
Pretty prints hashable elements based on pcOptHashes in the
 PrettyCookedOpts. This cannot be made an instance as it would be
 undecidable (the hope was (ToHash a) => PrettyCooked a)
prettyItemize :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> DocCooked -> a -> DocCooked Source #
Print an item list with a title
>>>prettyCookedOpts opts "Foo" "-" ["bar1", "bar2", "bar3"]Foo - bar1 - bar2 - bar3
prettyItemizeNoTitle :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> a -> DocCooked Source #
Print an item list without a title
prettyItemizeNonEmpty :: PrettyCookedList a => PrettyCookedOpts -> DocCooked -> DocCooked -> a -> Maybe DocCooked Source #
Print an item list with a title, but only when the list is non-empty