HLint: use the &&& tooltip

I launched HLint in a small project and suggested that I use && &.

Example:

>>> cat st.hs f = (+) 10 g = (+) 1 main = print $ (\x -> (fx, gx)) 5 >>> hlint st.hs st.hs:4:17: Warning: Use &&& Found: \ x -> (fx, gx) Why not: f Control.Arrow.&&& g 1 suggestion 

I understand that \x -> (fx, gx) is a model and evaluates a sentence. However, Control.Arrow.&&& does not accept normal functions, but an arrow, so I cannot just use &&& as suggested.

So what is the recommended way in this situation?

  • to define own operator &&& for function?
  • use the arrow and do something like (arr f) &&& (arr g) , but I don’t even know how to evaluate it?
  • ignore hlint in this particular case.
+7
haskell arrows hlint
source share
1 answer

Arrow is a type class of which (->) is an instance (see here in the "Instances" section and here for implementation). This means that you can directly use arrow operators such as (&&&) with functions.

+15
source share

All Articles