nthable-0.1

Data.Nthable

Description

Generalizes snd, fst, and so on.

Synopsis

Documentation

class Pos n => Nthable t n a | t n -> a whereSource

A class that knows how to access the nth member of a type.

Methods

nth :: n -> t -> aSource

Example:

 nth d1 (1,2) == 1
 nth d2 (1,2) == 2
 nth d3 (1,2) == error!

Instances

Nthable (a, b) D2 b 
Nthable (a, b) D1 a 
Nthable (a, b, c) D3 c 
Nthable (a, b, c) D2 b 
Nthable (a, b, c) D1 a 
Nthable (a, b, c, d) D4 d 
Nthable (a, b, c, d) D3 c 
Nthable (a, b, c, d) D2 b 
Nthable (a, b, c, d) D1 a 
Nthable (a, b, c, d, e) D5 e 
Nthable (a, b, c, d, e) D4 d 
Nthable (a, b, c, d, e) D3 c 
Nthable (a, b, c, d, e) D2 b 
Nthable (a, b, c, d, e) D1 a 
Nthable (a, b, c, d, e, f) D6 f 
Nthable (a, b, c, d, e, f) D5 e 
Nthable (a, b, c, d, e, f) D4 d 
Nthable (a, b, c, d, e, f) D3 c 
Nthable (a, b, c, d, e, f) D2 b 
Nthable (a, b, c, d, e, f) D1 a 
Nthable (a, b, c, d, e, f, g) D7 g 
Nthable (a, b, c, d, e, f, g) D6 f 
Nthable (a, b, c, d, e, f, g) D5 e 
Nthable (a, b, c, d, e, f, g) D4 d 
Nthable (a, b, c, d, e, f, g) D3 c 
Nthable (a, b, c, d, e, f, g) D2 b 
Nthable (a, b, c, d, e, f, g) D1 a 

fst :: Nthable n D1 a => n -> aSource

fst extended to work on any Nthable type.

snd :: Nthable n D2 a => n -> aSource

snd extended to work on any Nthable type.

thrd :: Nthable n D3 a => n -> aSource

frth :: Nthable n D4 a => n -> aSource

ffth :: Nthable n D5 a => n -> aSource

sxth :: Nthable n D6 a => n -> aSource

svnth :: Nthable n D7 a => n -> aSource