Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor 'tappend' #2

Open
ocramz opened this issue Apr 9, 2020 · 1 comment
Open

Refactor 'tappend' #2

ocramz opened this issue Apr 9, 2020 · 1 comment

Comments

@ocramz
Copy link

ocramz commented Apr 9, 2020

in Data.Align, 'tappend' is clearly partial, moreover it discards some information (the tail of the second Trace). Isn't there a better way to do this?

mt `tappend` (Trace z (t:_)) =
    fmap (\(Trace s ts) -> Trace (s+z) (t:ts)) mt
@robinp
Copy link
Owner

robinp commented Apr 9, 2020

Hi! If you look at the 3 callsites, it is clear that the second argument is always a singleton list. I don't remember why I abused the second argument into a Trace, this should probably just be a more specific function, getting the two args directly (instead of passing them through a Trace).

While there, it needs typesig, and the fmap should be moved to the callsite. In fact, this can just be a local helper near the callsite. Thanks for bringing up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants