Closed marcellussiegburg closed 4 months ago
@jvoigtlaender It addresses the first point of #9 by making it optional to pretty print the result (and requiring to provide such function, thus avoiding an additional constraint).
and requiring to provide such function
It requires a function a -> String
. But at least the use case where the problem appeared (https://github.com/fmidue/logic-tasks/issues/81#issuecomment-1917269129) would immediately have had an a -> Doc
at hand. That is, the natural thing there would have been to call testTask (Just pretty) ...
.
Would changing the argument to Maybe (a -> Doc)
introduce a problematic dependency? Or what would one write in testTask (Just ...)
to satisfy the -> String
?
I guess it is okay to introduce the dependency. It limits the pretty function to this Doc
type, but I guess that is fine (because if it does, it should use it anyway for Autotool tasks).
Actually not sure now what "this Doc
" type is. In logic-tasks
, Doc
comes from Daan's library, but that's not the Doc
inside Autotool, right?
So maybe using Doc
here is indeed too specific.
Or what would one write in
testTask (Just ...)
to satisfy the-> String
?
Just ...
could be Just (T.pack . displayTStrict . pretty)
Oh, why pack
? Wouldn't that give Text
instead of String
?
Oh, right. Sorry, this should be T.unpack
Hmm, Just (show . pretty)
wouldn't work? The code with displayStrict
etc. seems unwieldy and in particular is something one probably wouldn't remember in a debugging session.
This latest attempt provides liberty onto how to pretty print. In the aforementioned case one would use Just AutoLeijen
. [But would also be allowed to write Just (Manual $ T.unpack . PP.displayTStrict . PP.renderPretty 0.4 80 . PP.pretty)
; or better in other cases, if a not yet supported Pretty-Library is used. Leijen
might also be hard to remember, but should appear in the import List!]