ciren / cilib

Typesafe, purely functional Computational Intelligence
https://cilib.net
Apache License 2.0
124 stars 101 forks source link

Pretty printer #300

Closed KyleErwin closed 4 years ago

KyleErwin commented 6 years ago

New functionality to improve the output of examples. An object, PrettyPrinter has been added to the io package that contains implicit instances of EncodeDoc for common types used throughout the example package. Where EncodeDoc is the following

sealed trait EncodeDoc[A] {
    def toDoc(x: A): Doc
}

And Doc is a type from typelevel/paiges that allows text to be rendered with a given width size.

Examples that make use of PrettyPrinter are

If the design and implementation of the PrettyPrinter is correct PrettyPrinter functionality can be added to all examples where applicable.

There is also a public method within PrettyPrinter for creating new instances of EncodeDoc if users which to use their own types.

Example output below image