
Hi Deech,
Trying some things in Hugs:
Hugs> :t (+1)
flip (+) 1 :: Num a => a -> a
Hugs> :t (<0)
flip (<) 0 :: (Num a, Ord a) => a -> Bool
Hugs> :t (-1)
-1 :: Num a => a
If you see, Haskell interprets the first two as sections, but the last
one is treated as a unary minus, inside brackets - i.e. as though you
typed the numeric literal -1.
Haskell's treatment of negative literals is sometimes confusing...
Thanks
Neil
On 11/11/06, Aditya Siram
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
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe