polymorphism - What is the "a" in "List a" in the length example? -


i'm wondering can find information "a" used in length example. seems type of kind?

[1,2,3] list int, functions work lists of ints have have list int in type signature. ["a", "b"] list string, functions work lists of strings have have list string in type signature. function works list of type (for example list.length) can have generic type signature (like list a or list b). meaning of a relevant within type signature. example function type of list -> a, when given list int return int. when given list string return string.

take example map function has signature of (a -> b) -> list -> list b. says given function takes a , returns b, , list a, return list b.

given function takes string , returns int, , list string, map return list int.

list.map string.length ["a", "aa", "aaa"] -- [1, 2, 3] : list int 

given function takes int , returns string, , list int, map return list string.

list.map (\n -> string.repeat n "a") [1, 2, 3] -- ["a", "aa", "aaa"] : list string 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -