[Haskell-cafe] Deepest polymorphic functor

Eduard Sergeev Eduard.Sergeev at gmail.com
Fri Jul 31 02:26:08 EDT 2009



Ryan Ingram wrote:
> 
> The problem is this:
> 
>> instance Num a => Num [a] where ...
>>
>> test = deep_fmap (+1) [[[ 1, 2, 3 :: Int ]]]
> 
> What (+1) should be used?
> 
> (+1) :: Int -> Int
> (+1) :: [Int] -> [Int]
> (+1) :: [[Int]] -> [[Int]]
> (+1) :: [[[Int]]] -> [[[Int]]]
> 
> They could all be type-correct, so the snippet is ambiguous.

But why then the following snippet doesn't cause ambiguity:

deep_fmap (++"a") "b"  // -> "ba"
deep_fmap (++"a") ["b"]  // -> ["ba"]
deep_fmap (++"a") [["b"]]  // -> [["ba"]]
-- 
View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24751663.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list