Haskell equivalent of SML-like "return a function"

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
Dragonfall
Messages
1,023
Reaction score
5
I want do the Haskell equivalent of SML-like "return a function"

fun foo x = fn x=>x+1

How do I do this in Haskell?
 
Physics news on Phys.org
Code:
foo :: a -> Int -> Int
foo x = \x -> x+1

This can be written more concisely as:

Code:
foo = const (+1)
 
Hi,People! I need to define in haskell a function which ignore all doublings . For example if i type a string "abaacccdee" in the end i get the string "abacde".