fork download
  1. type Adder = Int -> Int
  2.  
  3. makeAdder :: (Int -> Int -> Int) -> Int -> Adder
  4. makeAdder f = f
  5.  
  6. makeGoodAdder = makeAdder (+)
  7. makeBadAdder = makeAdder (*)
  8.  
  9. testAdder cons delta value = let adder = cons delta in
  10. value + delta == adder value
  11.  
  12. main = do
  13. print $ testAdder makeGoodAdder 2 3
  14. print $ testAdder makeBadAdder 2 3
  15.  
Success #stdin #stdout 0s 4684KB
stdin
Standard input is empty
stdout
True
False