h2jvm
Safe HaskellNone
LanguageGHC2021

JVM.Data.Pretty

Synopsis

Documentation

showPretty :: (IsString s, Pretty a) => a -> s Source #

tracePrettyId :: Pretty a => a -> a Source #

class Pretty a where Source #

Overloaded conversion to Doc.

Laws:

  1. output should be pretty. :-)

Minimal complete definition

pretty

Methods

pretty :: a -> Doc ann Source #

>>> pretty 1 <+> pretty "hello" <+> pretty 1.234
1 hello 1.234

default pretty :: Show a => a -> Doc ann Source #

prettyList :: [a] -> Doc ann Source #

prettyList is only used to define the instance Pretty a => Pretty [a]. In normal circumstances only the pretty function is used.

>>> prettyList [1, 23, 456]
[1, 23, 456]

Instances

Instances details
Pretty Void Source #

Finding a good example for printing something that does not exist is hard, so here is an example of printing a list full of nothing.

>>> pretty ([] :: [Void])
[]
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Void -> Doc ann Source #

prettyList :: [Void] -> Doc ann Source #

Pretty Int16 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Int16 -> Doc ann Source #

prettyList :: [Int16] -> Doc ann Source #

Pretty Int32 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Int32 -> Doc ann Source #

prettyList :: [Int32] -> Doc ann Source #

Pretty Int64 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Int64 -> Doc ann Source #

prettyList :: [Int64] -> Doc ann Source #

Pretty Int8 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Int8 -> Doc ann Source #

prettyList :: [Int8] -> Doc ann Source #

Pretty Word16 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Word16 -> Doc ann Source #

prettyList :: [Word16] -> Doc ann Source #

Pretty Word32 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Word32 -> Doc ann Source #

prettyList :: [Word32] -> Doc ann Source #

Pretty Word64 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Word64 -> Doc ann Source #

prettyList :: [Word64] -> Doc ann Source #

Pretty Word8 Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Word8 -> Doc ann Source #

prettyList :: [Word8] -> Doc ann Source #

Pretty Label Source # 
Instance details

Defined in JVM.Data.Abstract.Builder.Label

Methods

pretty :: Label -> Doc ann Source #

prettyList :: [Label] -> Doc ann Source #

Pretty ClassFile Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile

Methods

pretty :: ClassFile -> Doc ann Source #

prettyList :: [ClassFile] -> Doc ann Source #

Pretty ClassFileAttribute Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile

Pretty InnerClassInfo Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile

Pretty ClassAccessFlag Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.AccessFlags

Pretty FieldAccessFlag Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.AccessFlags

Pretty MethodAccessFlag Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.AccessFlags

Pretty ClassFileField Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Field

Pretty ConstantValue Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Field

Pretty FieldAttribute Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Field

Pretty ClassFileMethod Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty CodeAttribute Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty CodeAttributeData Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty ExceptionTableEntry Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty LineNumberTableEntry Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty MethodAttribute Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty StackMapFrame Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty VerificationTypeInfo Source # 
Instance details

Defined in JVM.Data.Abstract.ClassFile.Method

Pretty BootstrapArgument Source # 
Instance details

Defined in JVM.Data.Abstract.ConstantPool

Pretty BootstrapMethod Source # 
Instance details

Defined in JVM.Data.Abstract.ConstantPool

Pretty FieldRef Source # 
Instance details

Defined in JVM.Data.Abstract.ConstantPool

Methods

pretty :: FieldRef -> Doc ann Source #

prettyList :: [FieldRef] -> Doc ann Source #

Pretty MethodHandleEntry Source # 
Instance details

Defined in JVM.Data.Abstract.ConstantPool

Pretty MethodRef Source # 
Instance details

Defined in JVM.Data.Abstract.ConstantPool

Methods

pretty :: MethodRef -> Doc ann Source #

prettyList :: [MethodRef] -> Doc ann Source #

Pretty MethodDescriptor Source # 
Instance details

Defined in JVM.Data.Abstract.Descriptor

Pretty ReturnDescriptor Source # 
Instance details

Defined in JVM.Data.Abstract.Descriptor

Pretty LDCEntry Source # 
Instance details

Defined in JVM.Data.Abstract.Instruction

Methods

pretty :: LDCEntry -> Doc ann Source #

prettyList :: [LDCEntry] -> Doc ann Source #

Pretty QualifiedClassName Source # 
Instance details

Defined in JVM.Data.Abstract.Name

Pretty ClassInfoType Source # 
Instance details

Defined in JVM.Data.Abstract.Type

Pretty FieldType Source # 
Instance details

Defined in JVM.Data.Abstract.Type

Methods

pretty :: FieldType -> Doc ann Source #

prettyList :: [FieldType] -> Doc ann Source #

Pretty PrimitiveType Source # 
Instance details

Defined in JVM.Data.Abstract.Type

Pretty LocalVariable Source # 
Instance details

Defined in JVM.Data.Analyse.StackMap

Pretty StackEntry Source # 
Instance details

Defined in JVM.Data.Analyse.StackMap

Pretty JVMVersion Source # 
Instance details

Defined in JVM.Data.JVMVersion

Pretty Text Source #

Automatically converts all newlines to line.

>>> pretty ("hello\nworld" :: Text)
hello
world

Note that line can be undone by group:

>>> group (pretty ("hello\nworld" :: Text))
hello world

Manually use hardline if you definitely want newlines.

Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Text -> Doc ann Source #

prettyList :: [Text] -> Doc ann Source #

Pretty Text Source #

(lazy Text instance, identical to the strict version)

Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Text -> Doc ann Source #

prettyList :: [Text] -> Doc ann Source #

Pretty Integer Source #
>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Integer -> Doc ann Source #

prettyList :: [Integer] -> Doc ann Source #

Pretty Natural Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Natural -> Doc ann Source #

prettyList :: [Natural] -> Doc ann Source #

Pretty () Source #
>>> pretty ()
()

The argument is not used:

>>> pretty (error "Strict?" :: ())
()
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: () -> Doc ann Source #

prettyList :: [()] -> Doc ann Source #

Pretty Bool Source #
>>> pretty True
True
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Bool -> Doc ann Source #

prettyList :: [Bool] -> Doc ann Source #

Pretty Char Source #

Instead of (pretty 'n'), consider using line as a more readable alternative.

>>> pretty 'f' <> pretty 'o' <> pretty 'o'
foo
>>> pretty ("string" :: String)
string
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Char -> Doc ann Source #

prettyList :: [Char] -> Doc ann Source #

Pretty Double Source #
>>> pretty (exp 1 :: Double)
2.71828182845904...
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Double -> Doc ann Source #

prettyList :: [Double] -> Doc ann Source #

Pretty Float Source #
>>> pretty (pi :: Float)
3.1415927
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Float -> Doc ann Source #

prettyList :: [Float] -> Doc ann Source #

Pretty Int Source #
>>> pretty (123 :: Int)
123
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Int -> Doc ann Source #

prettyList :: [Int] -> Doc ann Source #

Pretty Word Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Word -> Doc ann Source #

prettyList :: [Word] -> Doc ann Source #

Pretty a => Pretty (NonEmpty a) Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: NonEmpty a -> Doc ann Source #

prettyList :: [NonEmpty a] -> Doc ann Source #

Pretty a => Pretty (Identity a) Source #
>>> pretty (Identity 1)
1
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Identity a -> Doc ann Source #

prettyList :: [Identity a] -> Doc ann Source #

Pretty a => Pretty (TypeMergingList a) Source # 
Instance details

Defined in Data.TypeMergingList

Pretty label => Pretty (Instruction' label) Source # 
Instance details

Defined in JVM.Data.Abstract.Instruction

Methods

pretty :: Instruction' label -> Doc ann Source #

prettyList :: [Instruction' label] -> Doc ann Source #

Pretty (Doc a) Source # 
Instance details

Defined in JVM.Data.Pretty

Methods

pretty :: Doc a -> Doc ann Source #

prettyList :: [Doc a] -> Doc ann Source #

Pretty a => Pretty (Maybe a) Source #

Ignore Nothings, print Just contents.

>>> pretty (Just True)
True
>>> braces (pretty (Nothing :: Maybe Bool))
{}
>>> pretty [Just 1, Nothing, Just 3, Nothing]
[1, 3]
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Maybe a -> Doc ann Source #

prettyList :: [Maybe a] -> Doc ann Source #

Pretty a => Pretty [a] Source #
>>> pretty [1,2,3]
[1, 2, 3]
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: [a] -> Doc ann Source #

prettyList :: [[a]] -> Doc ann Source #

(Pretty a1, Pretty a2) => Pretty (a1, a2) Source #
>>> pretty (123, "hello")
(123, hello)
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: (a1, a2) -> Doc ann Source #

prettyList :: [(a1, a2)] -> Doc ann Source #

Pretty a => Pretty (Const a b) Source # 
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Const a b -> Doc ann Source #

prettyList :: [Const a b] -> Doc ann Source #

(Pretty a1, Pretty a2, Pretty a3) => Pretty (a1, a2, a3) Source #
>>> pretty (123, "hello", False)
(123, hello, False)
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: (a1, a2, a3) -> Doc ann Source #

prettyList :: [(a1, a2, a3)] -> Doc ann Source #

(<+>) :: Doc ann -> Doc ann -> Doc ann infixr 6 Source #

(x <+> y) concatenates document x and y with a space in between.

>>> "hello" <+> "world"
hello world
x <+> y = x <> space <> y

hsep :: [Doc ann] -> Doc ann Source #

(hsep xs) concatenates all documents xs horizontally with <+>, i.e. it puts a space between all entries.

>>> let docs = Util.words "lorem ipsum dolor sit amet"
>>> hsep docs
lorem ipsum dolor sit amet

hsep does not introduce line breaks on its own, even when the page is too narrow:

>>> putDocW 5 (hsep docs)
lorem ipsum dolor sit amet

For automatic line breaks, consider using fillSep instead.

Orphan instances

Pretty (Doc a) Source # 
Instance details

Methods

pretty :: Doc a -> Doc ann Source #

prettyList :: [Doc a] -> Doc ann Source #