Yhc Core Primitives Proposal

1 | Primitive Name | Use Row | Primitive Semantics | Status | Arity | Strictness | Type Signature | Front-End Mappings | |||
---|---|---|---|---|---|---|---|---|---|---|---|

2 | Yhc | Hugs | GHC | ||||||||

3 | Arithmetic Primitives | ||||||||||

4 | ADD_W | Y | Add two integer values | M | 2 | All | Int -> Int -> Int | ADD_W | Prelude;primPlusInt | ||

5 | ADD_L | Y | Add two long integer values | ADD_W | 2 | All | Integer -> Integer -> Integer | YHC.Primitive;PrimIntegerAdd | Prelude;primPlusInteger | ||

6 | SUB_W | Y | Subtract two integer values | M | 2 | All | Int -> Int -> Int | SUB_W | Prelude;primMinusInt | ||

7 | SUB_L | Y | Subtract two long integer values | SUB_W | 2 | All | Integer -> Integer -> Integer | YHC.Primitive;PrimIntegerSub | Prelude;primMinusInteger | ||

8 | NEG_W | Y | Negate an integer value | M | 1 | All | Int -> Int | NEG_W | Prelude;primNegInt | ||

9 | NEG_L | Y | Negate a long integer value | NEG_W | 1 | All | Integer -> Integer | YHC.Primitive;PrimIntegerNeg | Prelude;primNegInteger | ||

10 | EQ_W | Y | Compare two integer values for equality | M | 2 | All | Int -> Int -> Bool | EQ_W | Prelude;primEqInt | ||

11 | EQ_L | Y | Compare two long integer values for equality | EQ_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerEq | Prelude;primEqInteger | ||

12 | EQ_C | Y | Compare two characters for equality | M | 2 | All | Char -> Char -> Bool | Prelude;primEqChar | |||

13 | NE_W | Y | Compare two integer values for non-equality | M | 2 | All | Int -> Int -> Bool | NE_W | |||

14 | NE_L | Y | Compare two long integer values for non-equality | NE_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerNe | |||

15 | LE_W | Y | Compare two integer values for less or equal | M | 2 | All | Int -> Int -> Bool | LE_W | |||

16 | LE_L | Y | Compare two long integer values for less or equal | LE_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerLe | |||

17 | LT_W | Y | Compare two integer values for less | M | 2 | All | Int -> Int -> Bool | LT_W | |||

18 | LT_L | Y | Compare two long integer values for less | LT_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerLt | |||

19 | GE_W | Y | Compare two integer values for greater or equal | M | 2 | All | Int -> Int -> Bool | GE_W | |||

20 | GE_L | Y | Compare two long integer values for greater or equal | GE_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerGe | |||

21 | GT_W | Y | Compare two integer values for greater | M | 2 | All | Int -> Int -> Bool | GT_W | |||

22 | GT_L | Y | Compare two long integer values for greater | GT_W | 2 | All | Integer -> Integer -> Bool | YHC.Primitive;primIntegerGt | |||

23 | CMP_W | Y | Compare two integer values | M | 2 | All | Int -> Int -> Ordering | Prelude;primCmpInt | |||

24 | CMP_L | Y | Compare two long integer values | CMP_W | 2 | All | Integer -> Integer -> Ordering | Prelude;primCmpInteger | |||

25 | CMP_C | Y | Compare two characters | M | 2 | All | Char -> Char -> Ordering | Prelude;primCmpChar | |||

26 | MUL_W | Y | Multiply two integer values | M | 2 | All | Int -> Int -> Int | MUL_W | Prelude;primMulInt | ||

27 | MUL_L | Y | Multiply two long integer values | MUL_W | 2 | All | Integer -> Integer -> Integer | YHC.Primitive;PrimIntegerMul | Prelude;primMulInteger | ||

28 | MOD_W | Y | Remainder of flooring integer division | M | 2 | All | Int -> Int -> Int | ||||

29 | MOD_L | Y | Remainder of flooring long integer division | MOD_W | 2 | All | Integer -> Integer -> Integer | ||||

30 | DIV_W | Y | Quotient of flooring integer division | M | 2 | All | Int -> Int -> Int | ||||

31 | DIV_L | Y | Quotient of flooring long integer division | DIV_W | 2 | All | Integer -> Integer -> Integer | ||||

32 | REM_W | Y | Remainder of trunc to zero integer division | M | 2 | All | Int -> Int -> Int | ||||

33 | REM_L | Y | Remainder of trunc to zero long integer division | REM_W | 2 | All | Integer -> Integer -> Integer | ||||

34 | QUOT_W | Y | Quotient of trunc to zero integer division | M | 2 | All | Int -> Int -> Int | ||||

35 | QUOT_L | Y | Quotient of trunc to zero long integer division | QUOT_W | 2 | All | Integer -> Integer -> Integer | ||||

36 | ADD_D | Y | Add two double precision values | M | 2 | All | Double -> Double -> Double | ADD_D | Prelude;primPlusDouble | ||

37 | ADD_F | Y | Add two floating point single precision values | ADD_D | 2 | All | Float -> Float -> Float | ADD_F | Prelude;primPlusFloat | ||

38 | ADD_D | Y | Subtract two double precision values | M | 2 | All | Double -> Double -> Double | SUB_D | Prelude;primMinusDouble | ||

39 | SUB_F | Y | Subtract two floating point single precision values | ADD_D | 2 | All | Float -> Float -> Float | SUB_F | Prelude;primMinusFloat | ||

40 | MUL_D | Y | Multiply two double precision values | M | 2 | All | Double -> Double -> Double | MUL_D | Prelude;primMulDouble | ||

41 | MUL_F | Y | Multiply two floating point single precision values | ADD_D | 2 | All | Float -> Float -> Float | MUL_F | Prelude;primMulFloat | ||

42 | DIV_D | Y | Divide two double precision values | M | 2 | All | Double -> Double -> Double | SLASH_D | Prelude;primDivDouble | ||

43 | DIV_F | Y | Divide two floating point single precision values | ADD_D | 2 | All | Float -> Float -> Float | SLASH_F | Prelude;primDivFloat | ||

44 | NEG_D | Y | Negate a double precision value | M | 1 | All | Float -> Float | NEG_D | Prelude;primNegDouble | ||

45 | NEG_F | Y | Negate a floating point single precision value | NEG_D | 1 | All | Float -> Float | NEG_F | Prelude;primNegFloat | ||

46 | ABS_W | Y | Absolute value of an integer | M | 1 | All | Int -> Int | YHC.Primitive;primIntAbs | |||

47 | ABS_L | Y | Absolute value of a long integer | ABS_W | 1 | All | Integer -> Integer | ||||

48 | ABS_D | Y | Absolute value of a double precision | M | 1 | All | Double -> Double | ||||

49 | ABS_F | Y | Absolute value of a floating | ABS_D | 1 | All | Float -> Float | ||||

50 | SIGNUM_W | Y | Sign of an integer | M | 1 | All | Int -> Int | YHC.Primitive;primIntSignum | |||

51 | SIGNUM_L | Y | Sign of a long integer | SIGNUM_W | 1 | All | Integer -> Integer | ||||

52 | SIGNUM_D | Y | Sign of a double | M | 1 | All | Double -> Double | ||||

53 | SIGNUM_F | Y | Sign of a float | SIGNUM_D | 1 | All | Float -> Float | ||||

54 | LE_D | Y | Compare two double values for less or equal | M | 2 | All | Double -> Double -> Bool | LE_D | |||

55 | LE_F | Y | Compare two floating values for less or equal | LE_D | 2 | All | Float -> Float -> Bool | LE_F | |||

56 | LT_D | Y | Compare two double values for less | M | 2 | All | Double -> Double -> Bool | LT_D | |||

57 | LT_F | Y | Compare two floating values for less | LT_D | 2 | All | Float -> Float -> Bool | LT_F | |||

58 | GE_D | Y | Compare two double values for greater or equal | M | 2 | All | Double -> Double -> Bool | GE_D | |||

59 | GE_F | Y | Compare two floating values for greater or equal | GE_D | 2 | All | Float -> Float -> Bool | GE_F | |||

60 | GT_D | Y | Compare two double values for greater | M | 2 | All | Double -> Double -> Bool | GT_D | |||

61 | GT_F | Y | Compare two floating values for greater | GT_D | 2 | All | Float -> Float -> Bool | GT_F | |||

62 | EQ_D | Y | Compare two double values for equality | E | 2 | All | Double -> Double -> Bool | EQ_D | |||

63 | EQ_F | Y | Compare two floating values for equality | E | 2 | All | Float -> Float -> Bool | EQ_F | |||

64 | NE_D | Y | Compare two double values for non-equality | E | 2 | All | Double -> Double -> Bool | EQ_D | |||

65 | NE_F | Y | Compare two floating values for non-equality | E | 2 | All | Float -> Float -> Bool | EQ_F | |||

66 | CMP_D | Y | Compare two double values | M | 2 | All | Double -> Double -> Ordering | Prelude;primCmpDouble | |||

67 | CMP_F | Y | Compare two floating values | CMP_D | 2 | All | Float -> Float -> Ordering | Prelude;primCmpFloat | |||

68 | CAST_LW | Y | Cast long integer to integer | M | 1 | All | Integer -> Int | YHC.Primitive;primIntFromInteger | Prelude;primIntegerToInt | ||

69 | CAST_WL | Y | Cast integer to long integer | M | 1 | All | Int -> Integer | YHC.Primitive;primIntegerFromInt | Prelude;primIntToInteger | ||

70 | CAST_LD | Y | Cast long integer to double | M | 1 | All | Integer -> Double | YHC.Primitive;primDoubleFromInteger | Prelude;primIntegerToDouble | ||

71 | Character/Unicode Primitives | ||||||||||

72 | MAX_C | Y | Maximal value of a character | M | 0 | None | Char | Prelude;primMaxChar | |||

73 | ISUPR_C | Y | Character in Unicode categories: Lu | Lt | M | 1 | All | Char -> Bool | Prelude;primIsUpper | |||

74 | ISLOW_C | Y | Character in Unicode categories: Ll | M | 1 | All | Char -> Bool | Prelude;primIsLower | |||

75 | ISALP_C | Y | Character in Unicode categories: Lu | Ll | Lt | Lm | Lo | M | 1 | All | Char -> Bool | Prelude;primIsAlpha | |||

76 | ISALN_C | Y | Character in Unicode categories: Lu through No | M | 1 | All | Char -> Bool | Prelude;primIsAlphaNum | |||

77 | ISPRT_C | Y | Character in Unicode catrgories: Lu through Zs | M | 1 | All | Char -> Bool | Prelude;isPrint | |||

78 | TOUPR_C | Y | Change character case to upper | M | 1 | All | Char -> Char | Prelude;toUpper | |||

79 | TOLOW_C | Y | Change character case to lower | M | 1 | All | Char -> Char | Prelude;toLower | |||

80 | TOTIT_C | Y | Change character case to title | TOUPR_C | 1 | All | Char -> Char | Hugs.Char;toTitle | |||

81 | UCAT_C | Y | Character Unicode category | M | 1 | All | Char -> Int | Hugs.Char;primUniGenCat | |||

82 | Math/Floating point Primitives | ||||||||||

83 | SIN_F | Y | Sine of a float | M | 1 | All | Float -> Float | Prelude;primSinFloat | |||

84 | COS_F | Y | Cosine of a float | M | 1 | All | Float -> Float | Prelude;primCosFloat | |||

85 | TAN_F | Y | Tangent of a float | M | 1 | All | Float -> Float | Prelude;primTanFloat | |||

86 | ASIN_F | Y | Arcsine of a float | M | 1 | All | Float -> Float | Prelude;primAsinFloat | |||

87 | ACOS_F | Y | Arccos. of a float | M | 1 | All | Float -> Float | Prelude;primAcosFloat | |||

88 | ATAN_F | Y | Arctan. of a float | M | 1 | All | Float -> Float | Prelude;primAtanFloat | |||

89 | EXP_F | Y | Exponent of a float | M | 1 | All | Float -> Float | Prelude;primExpFloat | |||

90 | LOG_F | Y | Nat. logarithm of a float | M | 1 | All | Float -> Float | Prelude;primLogFloat | |||

91 | SQRT_F | Y | Square root of a float | M | 1 | All | Float -> Float | Prelude;primSqrtFloat | |||

92 | SIN_D | Y | Sine of a double | M | 1 | All | Double -> Double | Prelude;primSinDouble | |||

93 | COS_D | Y | Cosine of a double | M | 1 | All | Double -> Double | Prelude;primCosDouble | |||

94 | TAN_D | Y | Tangent of a double | M | 1 | All | Double -> Double | Prelude;primTanDouble | |||

95 | ASIN_D | Y | Arcsine of a double | M | 1 | All | Double -> Double | Prelude;primAsinDouble | |||

96 | ACOS_D | Y | Arccos. of a double | M | 1 | All | Double -> Double | Prelude;primAcosDouble | |||

97 | ATAN_D | Y | Arctan. of a double | M | 1 | All | Double -> Double | Prelude;primAtanDouble | |||

98 | EXP_D | Y | Exponent of a double | M | 1 | All | Double -> Double | Prelude;primExpDouble | |||

99 | LOG_D | Y | Nat. logarithm of a double | M | 1 | All | Double -> Double | Prelude;primLogDouble | |||

100 | SQRT_D | Y | Square root of a double | M | 1 | All | Double -> Double | Prelude;primSqrtDouble | |||

101 | RADIX_F | Y | Constant 2 | M | 0 | Int | Prelude;primFloatRadix, Prelude;primDoubleRadix | ||||

102 | DIGITS_F | Y | Significant digits in a float | M | 0 | Int | Prelude;primFloatDigits | ||||

103 | MINEXP_F | Y | Minimal exponent of a float | M | 0 | Int | Prelude;primFloatMinExp | ||||

104 | MAXEXP_F | Y | Maximal exponent of a float | M | 0 | Int | Prelude;primFloatMaxExp | ||||

105 | ENC_F | Y | Encode a float from significand and exponent | M | 2 | All | Integer -> Int -> Float | Prelude;primFloatEncode | |||

106 | DEC_F | Y | Decode a float into significand and exponent | M | 1 | All | Float -> (Integer, Int) | Prelude;primFloatDecode | |||

107 | DIGITS_D | Y | Significant digits in a double | M | 0 | Int | Prelude;primDoubleDigits | ||||

108 | MINEXP_D | Y | Minimal exponent of a double | M | 0 | Int | Prelude;primDoubleMinExp | ||||

109 | MAXEXP_D | Y | Maximal exponent of a double | M | 0 | Int | Prelude;primDoubleMaxExp | ||||

110 | ENC_D | Y | Encode a double from significand and exponent | M | 2 | All | Integer -> Int -> Double | Prelude;primDoubleEncode | |||

111 | DEC_D | Y | Decode a double into significand and exponent | M | 1 | All | Double -> (Integer, Int) | Prelude;primDoubleDecode | |||

112 | Special purpose primitives | ||||||||||

113 | THROW_E | Y | Throw an exception | M | 1 | None | Exception -> a | Prelude;throw | |||

114 | Implementation-specific primitives | ||||||||||

115 | QRM_W | Y | Combination of QUOT_W and REM_W | M | 2 | All | Int -> Int -> (Int, Int) | Prelude;primQrmInt | |||

116 | QRM_L | Y | Combination of QUOT_L and REM_L | QRM_W | 2 | All | Integer -> Integer -> (Integer, Integer) | Prelude;primQrmInteger | |||

117 | STRICT_APP | Y | Strict application: always forces its argument | M | 2 | FT | (a -> b) -> a -> b | Prelude;$! | |||

118 | SEL_ELEM | Y | Select an Nth element from a data structure | M | 3 | FTT | a -> b -> Int -> c | Prelude._SEL | |||

119 | SHOWS_W | Y | Show an Int value | O | 3 | All | Int -> a -> String -> String | Prelude;primShowsInt | |||

120 | SHOWS_L | Y | Show and Integer value | SHOWS_W | 3 | All | Int -> a -> String -> String | Prelude;primShowsInteger |

1 | Author | Date | Comment |
---|---|---|---|

2 | golubovsky | General comment | This spreadsheet is expected to contain only "normal" primitives, that is, those mandatory to be implement by any backend. A "normal" Core is a linked Core containing only "normal" primitives. A Haskell source code which only calls "normal" primitives, and translates into "normal" Core, should on any platform for which there is a backend for, behave identically. The only exceptions possible are due to natural limitations of numeric computations, e. g. numbers of certain precision are only supported by a particular platform, etc. |

3 | golubovsky | 6/20/2008 | Primitive status: M for "mandatory": every backend should implement; E for "elective": implemented optionally, but if implemented, should conform; O for "overlay": may be either a primitive, or overlayed with some Haskell code. |

4 | Name of another primitive in the "Status" column means substitute: if a backend does not implement this primitive, it should treat it like one mentioned, e. g. only one length of integers is supported (Javascript) - ADD_S should be implemented as ADD_W. | ||

5 | Strictness: "All" means on all arguments, otherwise a list of numbers (1-based) | ||

6 | "Long" integers does not mean certain bitness, rather, like Haskell's Int vs. Integer | ||

7 | Front-end Mappings: columns show, for each particular front-end, how original primitive/function names map into these base primitives | ||

8 | Primitives are expected to return simple values, that is QuotRem cannot be a primitive | ||

9 | Comparison of floating values for equality really needs more attention | ||

10 | |||

11 | golubovsky | 6/20/2008 | It's yet to be decided whether backends should implement QUOT and REM, DIV and MOD separately, or also together tuple-wrapped |