Question

I am trying to create a list of type Pos (custom) but keep getting the following error:

Not in scope: type constructor or class `List'

Code:

import Data.List
type Pos = (Int, Int)
type PlayList = List Pos

The error comes up on the line where I define my type PlayList.

Any ideas? Using Haskell in EclipseFP

Was it helpful?

Solution

The list type is actually called [], so you'd want

type PlayList = [Pos]

Although you'll often see people write their own list implementation for playing with various techniques as

data List a = Nil | Cons a (List a)

which is isomorphic to (identical to except for name) the actual implementation of

data [a] = [] | a : [a]

Where Nil == [] and Cons == (:).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top