what is the difference between type "a" and type "t" in Haskell type signature?

alixander

is there any difference between the two types "a" and "t" in Haskell type signature or its only a different designation like type "a" and type "b"?

in https://www.haskell.org/tutorial/goodies.html type [a] is defined as followed:

[a] is the family of types consisting of, for every type a, the type of lists of a. Lists of integers (e.g. [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 not a valid example, since there is no single type that contains both 2 and 'b'.)

is this definition also applied for type "t" ?

an example might be :

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
  app :: [t] -> t -> [t]
Mark Seemann

In Haskell type definitions, type names always start with upper-case letters, whereas type variables always start with lower-case letters. These are normally called a, b, and so on, but can also be called f, m, t, and so on.

Often, the letters in the beginning of the alphabet are used for unbounded type variables, whereas you often see more specific type variables denoted with f, m, t, and so on.

In the particular example

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

t is specifically denoted as being an instance of the Foldable type class. t a means any Foldable 'container' that holds values of the type a.

When you look your other example

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

it might as well have said [a] -> a -> [a], if app is a 'free-standing' function. If, on the other hand, app belongs to a type class, that type class definition could contain a more specific definition of t.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What does `... -> t a ->...` mean in type signature in Haskell?

in typescript, What's the difference between these two index signature type?

What does type signature for `undefined` mean in Haskell?

Haskell: What does it mean for a type signature to be total?

Difference between call signature and function type

Haskell type signature for == and elem

Haskell `forever` type signature

Invisible type signature in Haskell

Invalid type signature for (:==) in haskell

Haskell MonadWriter type signature

Haskell - Signature and Type error

Understanding Haskell Type Signature

What is the difference between type conversion and type assertion?

What is the difference between a primitive type and an atomic type?

What is difference between Type Annotations and Type Inference?

What is the difference between "(type func())" and "type func()"

what is the difference between *[]Type and []*Type in go

What is the difference between Type Safety and Type Inference?

What is the way to describe the type signature of Haskell functions that are not type-specific?

What is the difference between Type and Class?

Difference between (Type) and Type

What's the difference between self-type `this: T =>` and `this: T`?

what is the difference between the type of nil and the type of type of nil in lua?

What's the difference between type name() and type name = type()?

What is a function signature and type?

What are the difference between generic Type(T) vs any in typescript

Right type signature for type parameter in Haskell

Finding type signature of a function in Haskell

Can't grok a haskell type signature "instance Misty ((->) t "