Why is GHCi typing this statement oddly?

前端 未结 1 1171
北恋
北恋 2021-01-11 22:42

In answering a question on stackoverflow, I noticed that GHCi (interactive) is assigning a too-restrictive type in a let statement. Namely, given the code,<

相关标签:
1条回答
  • 2021-01-11 23:22

    See the extended defaulting rules used in GHCi for an explanation of where the () is coming from.

    As for why the defaulting occurs in this case, compare the following:

    > let f x = maximum &&& id >>> fst &&& (\(m,l) -> length $ filter (==m) l) $ x
    > :t f
    f :: (Ord a) => [a] -> (a, Int)
    

    I assume this has something to do with bindings being monomorphic, but I'm not certain of the details.

    0 讨论(0)
提交回复
热议问题