Hlint suggestion: use uncurry

I have this line of code:

map (\(u,v) -> flatTorus n u v) gridUV

Hlint invites me to replace it with

map (uncurry (flatTorus n)) gridUV

What is the motivation for this proposal? Is it just for short, or something else (performance)? Because, although it is longer, I find the first code easier to read.

Actually, my question is more general, because this is just an example among others: are proposals Hlintusually based only on brevity motivation or are there other improvements behind the proposals?

+4
source share
2 answers

I think Hlint prefers to use uncurryit because it gives you an invariant representation of a callback. Lambda expressions are inherently sensitive to representation because

\(u, v) -> flatTorus n u v

equivalently

\(x, y) -> flatTorus n x y

.

uncurry - (, , ), , , , .

+2

.

(\(x, y) -> (,) x y) undefined = undefined
uncurry (,) undefined = (undefined, undefined)

- uncurry . , , .

+1

Source: https://habr.com/ru/post/1694913/


All Articles