What is the difference between type โ€œaโ€ and type โ€œtโ€ in a Haskell type signature?

Is there a difference between the two types โ€œaโ€ and โ€œtโ€ in a signature of type Haskell or only with a different designation of type โ€œaโ€ and type โ€œbโ€?

at https://www.haskell.org/tutorial/goodies.html Type [a] is defined as follows:

[a] - a family of types consisting of each type a, type lists a. Lists of integers (for example, [1,2,3]), lists of characters (['a', 'b', 'c']), even lists of lists of integers, etc., are all members of this family. (Note, however, that [2, 'b'] is invalid, for example, since there is no single type that contains both 2 and "b".)

Does this definition also apply to type "t"?

could be an example:

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
  app :: [t] -> t -> [t]
+4
source share
1 answer

In Haskell type definitions, type names always begin with uppercase letters, while type variables always begin with lowercase letters. Usually they are called a, band so on, but can also be caused by f, m, tetc.

Often the letters at the beginning of the alphabet is used for variables such as unlimited, while you often see more specific variables such as marked f, m, tetc.

In a specific example

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

tis definitely referred to as an instance of a type class Foldable. t ameans any Foldable"container" that contains type values a.

app :: [t] -> t -> [t]

[a] -> a -> [a], app "" . , , app , t.

+2

Source: https://habr.com/ru/post/1685681/


All Articles