[Haskell-beginners] How to get qualifiers into type
Daniel Trstenjak
daniel.trstenjak at gmail.com
Thu Jan 17 15:53:31 CET 2013
Hi Rustom,
On Thu, Jan 17, 2013 at 07:10:48PM +0530, Rustom Mody wrote:
> type Vertex = Ix a => a
> (so that a vertex can be used to index an adjacency-list-array)
Ix is a type class, so you can only create an instance for an existing type,
but not "rename" the type class to something else.
> That is to say that whenever 'Vertex' appears in a type signature, the Ix
> should 'float' out to the qualifier list
You add the constraint to the functions using the index:
element :: Ix a => a -> ListArray b -> b
element index array = ...
Greetings,
Daniel
More information about the Beginners
mailing list