File: Tuples.k

package info (click to toggle)
kaya 0.4.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,448 kB
  • ctags: 1,694
  • sloc: cpp: 9,536; haskell: 7,461; sh: 3,013; yacc: 910; makefile: 816; perl: 90
file content (40 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/** -*-C-*-ish
    Kaya standard library
    Copyright (C) 2004, 2005 Edwin Brady

    This file is distributed under the terms of the GNU Lesser General
    Public Licence. See COPYING for licence.
*/
"<summary>Tuple data types</summary>
<prose>This module contains the definitions for the Tuple data types. While tuples up to 6-tuples are defined by this module, it is better in most situations to use a more meaningful user-defined data type than the larger tuples.</prose>
<prose>It is automatically imported (via the Prelude module) unless
the <code>-noprelude</code> compiler option is used. Almost all programs
and modules will need to import this module.</prose>"
module Tuples;

"<summary>Sugared as (a,b)</summary>
<prose>This represents an arbitrary pair of values. <code>Pair(a,b)</code> can be written as <code>(a,b)</code> for compactness.</prose>"
public data Pair<a,b> = Pair(a fst, b snd);

"<summary>Sugared as (a,b,c)</summary>
<prose>This represents an arbitrary triple of values. <code>Triple(a,b,c)</code> can be written as <code>(a,b,c)</code> for compactness.</prose>
<prose>Tuples larger than <dataref>Pair</dataref>s are generally better represented as user-defined data types, to help code readability.</prose>"
public data Triple<a,b,c> = Triple(a fst, b snd, c third);

"<summary>Sugared as (a,b,c,d)</summary>
<prose>This represents an arbitrary set of four values. <code>Tuple4(a,b,c,d)</code> can be written as <code>(a,b,c,d)</code> for compactness.</prose>
<prose>Consider using a more meaningful data type instead of large Tuples, to make your code more readable.</prose>"
public data Tuple4<a,b,c,d> = Tuple4(a fst, b snd, c third, d fourth);

"<summary>Sugared as (a,b,c,d,e)</summary>
<prose>This represents an arbitrary set of five values. <code>Tuple5(a,b,c,d,e)</code> can be written as <code>(a,b,c,d,e)</code> for compactness.</prose>
<prose>Consider using a more meaningful data type instead of large Tuples, to make your code more readable.</prose>"
public data Tuple5<a,b,c,d,e> = Tuple5(a fst, b snd, c third, d fourth, e fifth);

"<summary>Sugared as (a,b,c,d,e,f)</summary>
<prose>This represents an arbitrary set of six values. <code>Tuple6(a,b,c,d,e,f)</code> can be written as <code>(a,b,c,d,e,f)</code> for compactness.</prose>
<prose>This is the largest Tuple size available in the standard library. Strongly consider using a more meaningful data type instead of large Tuples, to make your code more readable.</prose>"
public data Tuple6<a,b,c,d,e,f> = Tuple6(a fst, b snd, c third, d fourth, e fifth,
				  f sixth);
/* Do we need more than 6-tuples? To be honest, I think anything more
   than a pair is unlikely to have a use that isn't done better by an ADT. */