fmidue / output-blocks

0 stars 0 forks source link

add additional info to testTask (#9) #11

Closed marcellussiegburg closed 4 months ago

marcellussiegburg commented 4 months ago
marcellussiegburg commented 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).

jvoigtlaender commented 4 months ago

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?

marcellussiegburg commented 4 months ago

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).

jvoigtlaender commented 4 months ago

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.

marcellussiegburg commented 4 months ago

Or what would one write in testTask (Just ...) to satisfy the -> String?

Just ... could be Just (T.pack . displayTStrict . pretty)

jvoigtlaender commented 4 months ago

Oh, why pack? Wouldn't that give Text instead of String?

marcellussiegburg commented 4 months ago

Oh, right. Sorry, this should be T.unpack

jvoigtlaender commented 4 months ago

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.

marcellussiegburg commented 4 months ago

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!]