Scoped type variables make it possible to specify the particular type of a function in situations where it is not otherwise possible, which can in turn help avoid problems with the Monomorphism restriction.

This feature should be better documented in the Wiki, but this is a start.

1 Avoiding Scoped Type Variables

Although Scoped Type Variables are often a simple solution, they are not available in all compilers.
Often there is a solution that is Haskell 98.
First, there is

asTypeOf:: a -> a -> a
asTypeOf a b = a
.

It is used like

x `asTypeOf` y

and has the same value like

x

,
but type inference asserts that

x

and

y

have the same type.

Sometimes it helps to divide a big function into smaller ones and give each of the small functions a signature.
This also helps reading the program.

If this does not help, too, then use a helper function.
E.g. if you want to determine the size of an object a pointer points to,
then you might define a function like