[Haskell-cafe] Section Syntax Errors

Aditya Siram aditya_siram at hotmail.com
Sat Nov 11 14:51:23 EST 2006


Hi all,
I am learning about sections and currying from SOE. There are three 
functions below. The first is from SOE and the other two are my own practice 
functions. Why does the third function fail?

--Test for negative numbers (from SOE pg 109). This works
posInts :: [Integer] -> [Bool]
posInts = map (> 0)

--Add 1 to a list of numbers. This works.
addOne :: [Integer] -> [Integer]
addOne = map (+ 1)

--Subtract 1 from a list of numbers. This does NOT work.
--Fails in Hugs with:
--     Instance of Num (Integer -> Integer) required for definition of 
testSections
-- I tried : subOne :: Num a => [a] -> [a]
--    and : subOne :: [Float] -> [Float]
--in case the problem is with negative numbers. They both fail.
--Without any type signature I get:
--     Unresolved top level overloading
subOne :: [Integer] -> [Integer]
subOne = map (- 1)

Thanks...
Deech

_________________________________________________________________
Add a Yahoo! contact to Windows Live Messenger for a chance to win a free 
trip! 
http://www.imagine-windowslive.com/minisites/yahoo/default.aspx?locale=en-us&hmtagline



More information about the Haskell-Cafe mailing list