Is there a pretty pretty (or ostentatious) abstraction in Haskell?

Is there a standard way to print out values ​​for end-user consumption? Showclearly more convenient for debugging than what will work for this purpose, given the conventions surrounding its use and the limitation that read (show x) == x.

For example, there is at least no simple package such as

class (Show a) => PShow a where 
    pshow :: a -> String
    pshow = show

pprint :: (PShow a) => a -> IO () 
pprint = putStrLn . pshow

where the instances do something like

instance PShow MyType where
    pshow a = someUserFriendlyStringOf a

Please note that I am not asking for something that provides complex printing and formatting functions (I see several packages that do this) just for a simple abstraction, which is widely used, which allows pretty typing. Is there something like this?

+2
2

, -, ( , )

. , , , - . - , , , - , .

, read. Show , (, GHC) .

+2

Hoogle a -> String Language.Haskell.Pretty.

:

prettyPrintStyleMode:: a = > β†’ PPHsMode β†’ a β†’ String
pretty-print .

prettyPrintWithMode:: a = > PPHsMode β†’ a β†’ String
pretty-print .

prettyPrint:: a = > a β†’ String
pretty-print .

, , , ,

+2

Source: https://habr.com/ru/post/1607003/


All Articles