Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard Haskell function that prepends an extra parameter to a function

Tags:

haskell

I have a function a->b which is to be passed to something of (c->a->b) signature. I don't care about c will just ignore it. Is there a standard function that prepends useless parameters: (a->b) -> (c->a->b) ?

like image 453
Trident D'Gao Avatar asked Jul 17 '15 16:07

Trident D'Gao


People also ask

What is flip Haskell?

flip f takes its (first) two arguments in the reverse order of f. flip f takes its (first) two arguments in the reverse order of f.

What is a higher order function Haskell?

Elementary HaskellA function that takes another function (or several functions) as an argument is called a higher-order function.

What is a parameter in Haskell?

Parameters in Haskell are rather reversed compared to imperative or object oriented languages. In an object oriented language, the object to work on is the very first parameter. In a function call it is often written even before the function name, say file in file.write("bla") .

What does Elem do in Haskell?

Elem Function This function is used to check whether the supplied list contains a specific element or not. Accordingly, it either returns a true or a false. The following code checks whether the supplied list of elements contains the value 786.


1 Answers

It's called const:

> let foo = const :: (a -> b) -> (c -> a -> b)
like image 64
András Kovács Avatar answered Sep 22 '22 18:09

András Kovács