Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Haskell insist on removing the last argument of a function?

Tags:

haskell

This is the relevant code :

removeCard :: Card -> Tracker -> Tracker
removeCard card tracker = filter (\cTracker -> ctCard cTracker /= card) tracker

Haskell is giving me a warning here, saying it should be written without the tracker on each side. I find it easier to read my functions when all the arguments are there, as the argument names help clarify what the function does. I could reverse the order of the parameters, but it makes intuitive sense to me that if you're calling a removeCard function, the card to remove is the first parameter, so I don't want to do that either. Is there a strong argument in favor of removing the last parameter?

EDIT : The question originally said that Haskell was giving me an error, but that was a bug with Syntastic, it's just a warning.

like image 499
Marcus Buffett Avatar asked Nov 11 '14 01:11

Marcus Buffett


People also ask

Do Haskell functions terminate?

Termination of Haskell Functions Intuitively a specific function evaluation (where the value of every argument is supplied) is terminating if the Haskell evaluation strategy needs finitely many steps to compute the result completely.

What does flip function do in Haskell?

Flip simply takes a function and returns a function that is like our original function, only the first two arguments are flipped. We can implement it like so: flip' :: (a -> b -> c) -> (b -> a -> c) flip' f = g.


1 Answers

If you don't want this HLint warning, you can disable it. This module will not show it for any functions defined:

module Foo where
{-# ANN module "HLint: ignore Eta reduce" #-}

foo bar = show bar     
like image 186
that other guy Avatar answered Oct 19 '22 23:10

that other guy