home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / progs / prelude / PreludePrims.hi < prev    next >
Encoding:
Text File  |  1994-09-27  |  12.4 KB  |  259 lines  |  [TEXT/YHS2]

  1. -- interface.scm -- define interface to primitives
  2. --
  3. -- author :  Sandra & John
  4. -- date   :  24 Apr 1992
  5. --
  6. -- This file declares the interface to the runtime system primitives.
  7. -- The actual definitions for the Lisp functions all appear elsewhere;
  8. -- they all have names like prim.xxx.  (They can actually be macros
  9. -- instead of functions since they're never referenced by name.)
  10.  
  11. interface PreludePrims where
  12.  
  13. {-# Prelude #-}
  14.  
  15. import PreludeCore(Int,Integer,Float,Double,Char,Bool)
  16. import PreludeRational(Rational)
  17.  
  18. error :: String -> a
  19. primCharToInt :: Char -> Int
  20. primIntToChar :: Int -> Char
  21. primEqChar, primNeqChar, primLeChar, primGtChar, primLsChar, primGeChar
  22.   :: Char -> Char -> Bool
  23. primMaxChar :: Int
  24. primEqFloat, primNeqFloat, primLeFloat, primGtFloat, primLsFloat, primGeFloat
  25.   :: Float -> Float -> Bool
  26. primFloatMax, primFloatMin :: Float -> Float -> Float
  27. primEqDouble, primNeqDouble, primLeDouble, primGtDouble, 
  28.               primLsDouble, primGeDouble
  29.   :: Double -> Double -> Bool
  30. primDoubleMax, primDoubleMin :: Double -> Double -> Double
  31. primPlusFloat, primMinusFloat, primMulFloat, primDivFloat
  32.   :: Float -> Float -> Float
  33. primPlusDouble, primMinusDouble, primMulDouble, primDivDouble
  34.   :: Double -> Double -> Double
  35. primNegFloat, primAbsFloat :: Float -> Float
  36. primNegDouble, primAbsDouble :: Double -> Double
  37. primExpFloat, primLogFloat, primSqrtFloat, primSinFloat, primCosFloat,
  38.   primTanFloat, primAsinFloat, primAcosFloat, primAtanFloat, primSinhFloat,
  39.   primCoshFloat, primTanhFloat, primAsinhFloat, primAcoshFloat, primAtanhFloat
  40.   :: Float -> Float
  41. primAtan2Float :: Float -> Float -> Float
  42. primExpDouble, primLogDouble, primSqrtDouble, primSinDouble, primCosDouble,
  43.   primTanDouble, primAsinDouble, primAcosDouble, primAtanDouble, primSinhDouble,
  44.   primCoshDouble, primTanhDouble, primAsinhDouble, primAcoshDouble, primAtanhDouble
  45.   :: Double -> Double
  46. primAtan2Double :: Double -> Double -> Double
  47. primPiFloat :: Float
  48. primPiDouble :: Double
  49. primRationalToFloat :: Rational -> Float
  50. primRationalToDouble :: Rational -> Double
  51. primFloatToRational :: Float -> Rational
  52. primDoubleToRational :: Double -> Rational
  53. primFloatDigits :: Int
  54. primFloatRadix :: Integer
  55. primFloatMinExp :: Int
  56. primFloatMaxExp :: Int
  57. primFloatRange :: Float -> (Int, Int)
  58. primDecodeFloat :: Float -> (Integer, Int)
  59. primEncodeFloat :: Integer -> Int -> Float
  60. primDoubleDigits :: Int
  61. primDoubleRadix :: Integer
  62. primDoubleMinExp :: Int
  63. primDoubleMaxExp :: Int
  64. primDoubleRange :: Double -> (Int, Int)
  65. primDecodeDouble :: Double -> (Integer, Int)
  66. primEncodeDouble :: Integer -> Int -> Double
  67. primEqInt, primNeqInt, primLeInt, primGtInt, primLsInt, primGeInt
  68.   :: Int -> Int -> Bool
  69. primIntMax, primIntMin :: Int -> Int -> Int
  70. primEqInteger, primNeqInteger, primLeInteger, primGtInteger,
  71.   primLsInteger, primGeInteger
  72.     :: Integer -> Integer -> Bool
  73. primIntegerMax, primIntegerMin :: Integer -> Integer -> Integer
  74. primPlusInt, primMinusInt, primMulInt :: Int -> Int -> Int 
  75. primMinInt,primMaxInt :: Int
  76. primNegInt, primAbsInt :: Int -> Int
  77. primPlusInteger, primMinusInteger, primMulInteger :: Integer -> Integer -> Integer 
  78. primNegInteger, primAbsInteger :: Integer -> Integer
  79. primQuotRemInt :: Int -> Int -> (Int, Int)
  80. primQuotRemInteger :: Integer -> Integer -> (Integer, Integer)
  81. primIntegerToInt :: Integer -> Int
  82. primIntToInteger :: Int -> Integer
  83. primNullBin :: Bin
  84. primIsNullBin :: Bin -> Bool
  85. primShowBinInt :: Int -> Bin -> Bin
  86. primShowBinInteger :: Integer -> Bin -> Bin
  87. primShowBinFloat :: Float -> Bin -> Bin
  88. primShowBinDouble :: Double -> Bin -> Bin
  89. primReadBinInt :: Bin -> (Int,Bin)
  90. primReadBinInteger :: Bin -> (Integer,Bin)
  91. primReadBinFloat :: Bin -> (Float,Bin)
  92. primReadBinDouble :: Bin -> (Double,Bin)
  93. primReadBinSmallInt :: Bin -> Int -> (Int,Bin)
  94. primAppendBin :: Bin -> Bin -> Bin
  95.  
  96. primStringEq  :: [Char] -> [Char] -> Bool
  97.  
  98. primAppend :: [a] -> [a] -> [a]
  99. primTake :: Int -> [a] -> [a]
  100.  
  101. foldr :: (a -> b -> b) -> b -> [a] -> b
  102. build :: ((a -> [a] -> [a]) -> [b] -> [c]) -> [c]
  103.  
  104. strict2 :: a -> b -> b
  105.  
  106.  
  107. -- I've assigned complexities for arithmetic primitives as follows:
  108. -- Int and Char comparisons and arithmetic are very cheap (complexity 1).
  109. -- Double and Float comparsions are also cheap, but most implementations
  110. --   need to box the results of floating-point arithmetic so I have given
  111. --   them a complexity of 3.
  112. -- Integer operations need to do an extra bignum check that has a fixed
  113. --   overhead.  I assume that actual bignums will be rare and give them
  114. --   all a complexity of 2.
  115.  
  116. {-#
  117. error :: LispName("prim.abort")
  118. primCharToInt ::    LispName("prim.char-to-int"), Complexity(0),NoConversion
  119. primIntToChar ::    LispName("prim.int-to-char"), Complexity(0),NoConversion
  120. primEqChar ::       LispName("prim.eq-char"), Complexity(1), NoConversion
  121. primNeqChar::       LispName("prim.not-eq-char"), Complexity(1), NoConversion
  122. primLeChar ::       LispName("prim.le-char"), Complexity(1), NoConversion
  123. primGtChar ::       LispName("prim.not-le-char"), Complexity(1), NoConversion
  124. primLsChar ::       LispName("prim.lt-char"), Complexity(1), NoConversion
  125. primGeChar ::       LispName("prim.not-lt-char"), Complexity(1), NoConversion
  126. primMaxChar ::      LispName("prim.max-char"), NoConversion
  127. primEqFloat ::      LispName("prim.eq-float"), Complexity(1)
  128. primNeqFloat ::     LispName("prim.not-eq-float"), Complexity(1)
  129. primLeFloat  ::     LispName("prim.le-float"), Complexity(1)
  130. primGtFloat  ::     LispName("prim.not-le-float"), Complexity(1)
  131. primLsFloat  ::     LispName("prim.lt-float"), Complexity(1)
  132. primGeFloat  ::     LispName("prim.not-lt-float"), Complexity(1)
  133. primFloatMax ::     LispName("prim.float-max"), Complexity(3)
  134. primFloatMin ::     LispName("prim.float-min"), Complexity(3)
  135. primEqDouble  ::    LispName("prim.eq-double"), Complexity(1)
  136. primNeqDouble ::    LispName("prim.not-eq-double"), Complexity(1)
  137. primLeDouble  ::    LispName("prim.le-double"), Complexity(1)
  138. primGtDouble  ::    LispName("prim.not-le-double"), Complexity(1)
  139. primLsDouble  ::    LispName("prim.lt-double"), Complexity(1)
  140. primGeDouble  ::    LispName("prim.not-lt-double"), Complexity(1)
  141. primDoubleMax ::    LispName("prim.double-max"), Complexity(3)
  142. primDoubleMin ::    LispName("prim.double-min"), Complexity(3)
  143. primPlusFloat  ::   LispName("prim.plus-float"), Complexity(3)
  144. primMinusFloat ::   LispName("prim.minus-float"), Complexity(3)
  145. primMulFloat   ::   LispName("prim.mul-float"), Complexity(3)
  146. primDivFloat   ::   LispName("prim.div-float"), Complexity(3)
  147. primPlusDouble  ::  LispName("prim.plus-double"), Complexity(3)
  148. primMinusDouble ::  LispName("prim.minus-double"), Complexity(3)
  149. primMulDouble   ::  LispName("prim.mul-double"), Complexity(3)
  150. primDivDouble   ::  LispName("prim.div-double"), Complexity(3)
  151. primNegFloat ::     LispName("prim.neg-float"), Complexity(3)
  152. primAbsFloat ::     LispName("prim.abs-float"), Complexity(3)
  153. primNegDouble ::    LispName("prim.neg-double"), Complexity(3)
  154. primAbsDouble ::    LispName("prim.abs-double"), Complexity(3)
  155. primExpFloat   ::   LispName("prim.exp-float")
  156. primLogFloat   ::   LispName("prim.log-float")
  157. primSqrtFloat  ::   LispName("prim.sqrt-float")
  158. primSinFloat   ::   LispName("prim.sin-float")
  159. primCosFloat   ::   LispName("prim.cos-float")
  160. primTanFloat   ::   LispName("prim.tan-float")
  161. primAsinFloat  ::   LispName("prim.asin-float")
  162. primAcosFloat  ::   LispName("prim.acos-float")
  163. primAtanFloat  ::   LispName("prim.atan-float")
  164. primSinhFloat  ::   LispName("prim.sinh-float")
  165. primCoshFloat  ::   LispName("prim.cosh-float")
  166. primTanhFloat  ::   LispName("prim.tanh-float")
  167. primAsinhFloat ::   LispName("prim.asinh-float")
  168. primAcoshFloat ::   LispName("prim.acosh-float")
  169. primAtanhFloat ::   LispName("prim.atanh-float")
  170. primAtan2Float ::   LispName("prim.atan2-float")
  171. primExpDouble   ::  LispName("prim.exp-double")
  172. primLogDouble   ::  LispName("prim.log-double")
  173. primSqrtDouble  ::  LispName("prim.sqrt-double")
  174. primSinDouble   ::  LispName("prim.sin-double")
  175. primCosDouble   ::  LispName("prim.cos-double")
  176. primTanDouble   ::  LispName("prim.tan-double")
  177. primAsinDouble  ::  LispName("prim.asin-double")
  178. primAcosDouble  ::  LispName("prim.acos-double")
  179. primAtanDouble  ::  LispName("prim.atan-double")
  180. primSinhDouble  ::  LispName("prim.sinh-double")
  181. primCoshDouble  ::  LispName("prim.cosh-double")
  182. primTanhDouble  ::  LispName("prim.tanh-double")
  183. primAsinhDouble ::  LispName("prim.asinh-double")
  184. primAcoshDouble ::  LispName("prim.acosh-double")
  185. primAtanhDouble ::  LispName("prim.atanh-double")
  186. primAtan2Double ::  LispName("prim.atan2-double")
  187. primPiFloat ::      LispName("prim.pi-float")
  188. primPiDouble ::     LispName("prim.pi-double")
  189. primRationalToFloat  :: LispName("prim.rational-to-float"), Complexity(3)
  190. primRationalToDouble :: LispName("prim.rational-to-double"), Complexity(3)
  191. primFloatToRational  :: LispName("prim.float-to-rational"), Complexity(3)
  192. primDoubleToRational :: LispName("prim.double-to-rational"), Complexity(3)
  193. primFloatDigits ::  LispName("prim.float-digits")
  194. primFloatRadix ::   LispName("prim.float-radix")
  195. primFloatMinExp ::  LispName("prim.float-min-exp")
  196. primFloatMaxExp ::  LispName("prim.float-max-exp")
  197. primFloatRange ::   LispName("prim.float-range")
  198. primDecodeFloat ::  LispName("prim.decode-float")
  199. primEncodeFloat ::  LispName("prim.encode-float")
  200. primDoubleDigits :: LispName("prim.double-digits")
  201. primDoubleRadix ::  LispName("prim.double-radix")
  202. primDoubleMinExp :: LispName("prim.double-min-exp")
  203. primDoubleMaxExp :: LispName("prim.double-max-exp")
  204. primDoubleRange ::  LispName("prim.double-range")
  205. primDecodeDouble :: LispName("prim.decode-double")
  206. primEncodeDouble :: LispName("prim.encode-double")
  207. primEqInt ::        LispName("prim.eq-int"), Complexity(1)
  208. primNeqInt::        LispName("prim.not-eq-int"), Complexity(1)
  209. primLeInt ::        LispName("prim.le-int"), Complexity(1)
  210. primGtInt ::        LispName("prim.not-le-int"), Complexity(1)
  211. primLsInt ::        LispName("prim.lt-int"), Complexity(1)
  212. primGeInt ::        LispName("prim.not-lt-int"), Complexity(1)
  213. primIntMax ::       LispName("prim.int-max"), Complexity(1)
  214. primIntMin ::       LispName("prim.int-min"), Complexity(1)
  215. primEqInteger ::    LispName("prim.eq-integer"), Complexity(2)
  216. primNeqInteger::    LispName("prim.not-eq-integer"), Complexity(2)
  217. primLeInteger ::    LispName("prim.le-integer"), Complexity(2)
  218. primGtInteger ::    LispName("prim.not-le-integer"), Complexity(2)
  219. primLsInteger ::    LispName("prim.lt-integer"), Complexity(2)
  220. primGeInteger ::    LispName("prim.not-lt-integer"), Complexity(2)
  221. primIntegerMax ::   LispName("prim.integer-max"), Complexity(2)
  222. primIntegerMin ::   LispName("prim.integer-min"), Complexity(2)
  223. primPlusInt  ::     LispName("prim.plus-int"), Complexity(1)
  224. primMinusInt ::     LispName("prim.minus-int"), Complexity(1)
  225. primMulInt   ::     LispName("prim.mul-int"), Complexity(1)
  226. primMinInt ::       LispName("prim.minint")
  227. primMaxInt ::       LispName("prim.maxint")
  228. primNegInt ::       LispName("prim.neg-int"), Complexity(1)
  229. primAbsInt ::       LispName("prim.abs-int"), Complexity(1)
  230. primPlusInteger  :: LispName("prim.plus-integer"), Complexity(2)
  231. primMinusInteger :: LispName("prim.minus-integer"), Complexity(2)
  232. primMulInteger   :: LispName("prim.mul-integer"), Complexity(2)
  233. primNegInteger ::   LispName("prim.neg-integer"), Complexity(2)
  234. primAbsInteger ::   LispName("prim.abs-integer"), Complexity(2)
  235. primQuotRemInt ::   LispName("prim.div-rem-int")
  236. primQuotRemInteger :: LispName("prim.div-rem-integer")
  237. primIntegerToInt :: LispName("prim.integer-to-int"), Complexity(1)
  238. primIntToInteger :: LispName("prim.int-to-integer"), Complexity(0)
  239. primNullBin ::      LispName("prim.nullbin")
  240. primIsNullBin ::    LispName("prim.is-null-bin"), Complexity(1)
  241. primShowBinInt ::   LispName("prim.show-bin-int"), Complexity(2)
  242. primShowBinInteger :: LispName("prim.show-bin-integer"), Complexity(2)
  243. primShowBinFloat ::   LispName("prim.show-bin-float"), Complexity(2)
  244. primShowBinDouble ::  LispName("prim.show-bin-double"), Complexity(2)
  245. primReadBinInt ::     LispName("prim.read-bin-int")
  246. primReadBinInteger :: LispName("prim.read-bin-integer")
  247. primReadBinFloat ::   LispName("prim.read-bin-float")
  248. primReadBinDouble ::  LispName("prim.read-bin-double")
  249. primReadBinSmallInt :: LispName("prim.read-bin-small-int")
  250. primAppendBin ::      LispName("prim.append-bin")
  251. primStringEq :: LispName("prim.string-eq"), Strictness("S,S"), NoConversion
  252. primAppend :: LispName("prim.append"), Strictness("S,N"), NoConversion
  253. primTake   :: LispName("prim.take"), Strictness("S,S"), NoConversion
  254. foldr   :: LispName("prim.foldr"), Strictness("N,N,S"), NoConversion
  255. build   :: LispName("prim.build"), Strictness("S"), NoConversion
  256. strict2 :: LispName("prim.strict2"), Strictness("S,S"), Complexity(0)
  257.  
  258. #-}
  259.