Skip to content

Add 'traces' function #301

@sushi-shi

Description

@sushi-shi

traceShowId is really useful because you can plug it in anywhere you want without restructuring your code, however, sometimes it outputs too much, or things you use it on do not have Show instance.
So I propose to add a simple traces function:

traces :: Show b => (a -> b) -> a -> a
traces f v = traceShow (f v) v

> fst $ traces fst (5, id)
> 5
> 5

Though it may clash with traces function defined in comonad package. However Control.Comonad.Traced also has trace, so one would need to be careful with this module anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    newBring something new into library (add function or type or interface)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions