cdepillabout / pretty-simple

pretty-printer for Haskell data types that have a Show instance
https://hackage.haskell.org/package/pretty-simple
BSD 3-Clause "New" or "Revised" License
243 stars 29 forks source link

Fix trace functions not pretty-printing as expected #20

Closed yigitozkavci closed 6 years ago

yigitozkavci commented 6 years ago

Fixes #19

Summary

This PR adds NoColor counterparts of trace functions, and implement tests on them (because testing colored output is awkward).

Notes

@cdepillabout There is a warning introduced with this PR:

warning: [-Wunused-imports]
    The qualified import of ‘Data.Map’ is redundant
      except perhaps to import instances from ‘Data.Map’
    To import instances alone, use: import Data.Map()

Even though I use it for Doctest, I get this warning. I see we didn't use a non-prelude library for our doctests before, but I want to handle a case with Map since @igrep noticed the bug with that data structure.

We can overcome this warning with {-# OPTIONS_GHC -fno-warn-unused-imports #-} pragma on this module. What do you think?

cdepillabout commented 6 years ago

@yigitozkavci Thanks for working on this.

There is a warning introduced with this PR:

warning: [-Wunused-imports]
   The qualified import of ‘Data.Map’ is redundant
     except perhaps to import instances from ‘Data.Map’
   To import instances alone, use: import Data.Map()

Even though I use it for Doctest, I get this warning. I see we didn't use a non-prelude library for our doctests before, but I want to handle a case with Map since @igrep noticed the bug with that data structure.

We can overcome this warning with {-# OPTIONS_GHC -fno-warn-unused-imports #-} pragma on this module. What do you think?

You should be able to import modules within the doctests.

Here's an example doctest showing this:

>>> import Data.List (nub)
>>> nub [1,2,3,1,1,1]
>>> [1,2,3]

Although, I don't necessarily think it is that important to use Data.Map. If you just want to use something like a list to write the tests, I think that should be fine as well.

yigitozkavci commented 6 years ago

That's perfect, first time using doctest, that's why :) Did the necessary changes 👍

cdepillabout commented 6 years ago

Okay, thanks. I'll merge this when the tests pass.

yigitozkavci commented 6 years ago

Also, I didn't add the @since annotations since I don't know the next release version. Can you add those? @cdepillabout