Difference between revisions of "Monomorphism"

From HaskellWiki
Jump to: navigation, search
m
(revert spam by TaalbOclim and TabocRelde)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
c4tcnaalc
 
 
[[Category:Glossary]]
 
[[Category:Glossary]]
   

Latest revision as of 20:01, 21 May 2017


Monomorphism is the opposite of polymorphism. That is, a function is polymorphic if it works for several different types - and thus, a function is monomorphic if it works only for one type.

As an example, map is polymorphic. It's type is simply

map :: (a -> b) -> [a] -> [b]

However, the function

foo :: (Int -> Int) -> [Int] -> [Int]
foo = map

performs an identical operation to map (as is evident from the second line), but has a monomorphic type; it will only accept lists of Int and functions over them.

Perhaps you were looking for monomorphism restriction?