summaryrefslogtreecommitdiff
path: root/progs/lib/cl
diff options
context:
space:
mode:
Diffstat (limited to 'progs/lib/cl')
-rw-r--r--progs/lib/cl/README2
-rw-r--r--progs/lib/cl/logop-prims.hi78
-rw-r--r--progs/lib/cl/logop-prims.scm81
-rw-r--r--progs/lib/cl/logop.hs63
-rw-r--r--progs/lib/cl/logop.hu5
-rw-r--r--progs/lib/cl/maybe.hs12
-rw-r--r--progs/lib/cl/maybe.hu3
-rw-r--r--progs/lib/cl/random-prims.hi20
-rw-r--r--progs/lib/cl/random.hs21
-rw-r--r--progs/lib/cl/random.hu4
10 files changed, 289 insertions, 0 deletions
diff --git a/progs/lib/cl/README b/progs/lib/cl/README
new file mode 100644
index 0000000..8164257
--- /dev/null
+++ b/progs/lib/cl/README
@@ -0,0 +1,2 @@
+This directory contains some libraries which allow you to use various
+Common Lisp primitives from Haskell.
diff --git a/progs/lib/cl/logop-prims.hi b/progs/lib/cl/logop-prims.hi
new file mode 100644
index 0000000..2b120bb
--- /dev/null
+++ b/progs/lib/cl/logop-prims.hi
@@ -0,0 +1,78 @@
+-- logop-prims.hi -- interface to logical operations on numbers
+--
+-- author : Sandra Loosemore
+-- date : 19 June 1993
+--
+
+interface LogOpPrims where
+
+logiorInteger :: Integer -> Integer -> Integer
+logxorInteger :: Integer -> Integer -> Integer
+logandInteger :: Integer -> Integer -> Integer
+logeqvInteger :: Integer -> Integer -> Integer
+lognandInteger :: Integer -> Integer -> Integer
+lognorInteger :: Integer -> Integer -> Integer
+logandc1Integer :: Integer -> Integer -> Integer
+logandc2Integer :: Integer -> Integer -> Integer
+logorc1Integer :: Integer -> Integer -> Integer
+logorc2Integer :: Integer -> Integer -> Integer
+lognotInteger :: Integer -> Integer
+logtestInteger :: Integer -> Integer -> Integer
+logbitpInteger :: Int -> Integer -> Integer
+ashInteger :: Integer -> Int -> Integer
+logcountInteger :: Integer -> Int
+integerLengthInteger :: Integer -> Int
+
+logiorInt :: Int -> Int -> Int
+logxorInt :: Int -> Int -> Int
+logandInt :: Int -> Int -> Int
+logeqvInt :: Int -> Int -> Int
+lognandInt :: Int -> Int -> Int
+lognorInt :: Int -> Int -> Int
+logandc1Int :: Int -> Int -> Int
+logandc2Int :: Int -> Int -> Int
+logorc1Int :: Int -> Int -> Int
+logorc2Int :: Int -> Int -> Int
+lognotInt :: Int -> Int
+logtestInt :: Int -> Int -> Int
+logbitpInt :: Int -> Int -> Int
+ashInt :: Int -> Int -> Int
+logcountInt :: Int -> Int
+integerLengthInt :: Int -> Int
+
+{-#
+logiorInteger :: LispName("logop.logior-integer"), Complexity(4)
+logxorInteger :: LispName("logop.logxor-integer"), Complexity(4)
+logandInteger :: LispName("logop.logand-integer"), Complexity(4)
+logeqvInteger :: LispName("logop.logeqv-integer"), Complexity(4)
+lognandInteger :: LispName("logop.lognand-integer"), Complexity(4)
+lognorInteger :: LispName("logop.lognor-integer"), Complexity(4)
+logandc1Integer :: LispName("logop.logandc1-integer"), Complexity(4)
+logandc2Integer :: LispName("logop.logandc2-integer"), Complexity(4)
+logorc1Integer :: LispName("logop.logorc1-integer"), Complexity(4)
+logorc2Integer :: LispName("logop.logorc2-integer"), Complexity(4)
+lognotInteger :: LispName("logop.lognot-integer"), Complexity(4)
+logtestInteger :: LispName("logop.logtest-integer"), Complexity(4)
+logbitpInteger :: LispName("logop.logbitp-integer"), Complexity(4)
+ashInteger :: LispName("logop.ash-integer"), Complexity(4)
+logcountInteger :: LispName("logop.logcount-integer"), Complexity(4)
+integerLengthInteger :: LispName("logop.integer-length-integer"), Complexity(4)
+
+logiorInt :: LispName("logop.logior-int"), Complexity(2)
+logxorInt :: LispName("logop.logxor-int"), Complexity(2)
+logandInt :: LispName("logop.logand-int"), Complexity(2)
+logeqvInt :: LispName("logop.logeqv-int"), Complexity(2)
+lognandInt :: LispName("logop.lognand-int"), Complexity(2)
+lognorInt :: LispName("logop.lognor-int"), Complexity(2)
+logandc1Int :: LispName("logop.logandc1-int"), Complexity(2)
+logandc2Int :: LispName("logop.logandc2-int"), Complexity(2)
+logorc1Int :: LispName("logop.logorc1-int"), Complexity(2)
+logorc2Int :: LispName("logop.logorc2-int"), Complexity(2)
+lognotInt :: LispName("logop.lognot-int"), Complexity(2)
+logtestInt :: LispName("logop.logtest-int"), Complexity(2)
+logbitpInt :: LispName("logop.logbitp-int"), Complexity(2)
+ashInt :: LispName("logop.ash-int"), Complexity(2)
+logcountInt :: LispName("logop.logcount-int"), Complexity(2)
+integerLengthInt :: LispName("logop.integer-length-int"), Complexity(2)
+#-}
+
diff --git a/progs/lib/cl/logop-prims.scm b/progs/lib/cl/logop-prims.scm
new file mode 100644
index 0000000..b846836
--- /dev/null
+++ b/progs/lib/cl/logop-prims.scm
@@ -0,0 +1,81 @@
+;;; logop-prims.scm -- primitives for logical operations on numbers
+;;;
+;;; author : Sandra Loosemore
+;;; date : 19 Jun 1993
+;;;
+
+
+;;; Integer operations
+;;; Note that bit counts are still guaranteed to be fixnums....
+
+(define-syntax (logop.logior-integer i1 i2)
+ `(the integer (lisp:logior (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logxor-integer i1 i2)
+ `(the integer (lisp:logxor (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logand-integer i1 i2)
+ `(the integer (lisp:logand (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logeqv-integer i1 i2)
+ `(the integer (lisp:logeqv (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.lognand-integer i1 i2)
+ `(the integer (lisp:lognand (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.lognor-integer i1 i2)
+ `(the integer (lisp:lognor (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logandc1-integer i1 i2)
+ `(the integer (lisp:logandc1 (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logandc2-integer i1 i2)
+ `(the integer (lisp:logandc2 (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logorc1-integer i1 i2)
+ `(the integer (lisp:logorc1 (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logorc2-integer i1 i2)
+ `(the integer (lisp:logorc2 (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.lognot-integer i1)
+ `(the integer (lisp:lognot (the integer ,i1))))
+(define-syntax (logop.logtest-integer i1 i2)
+ `(the integer (lisp:logtest (the integer ,i1) (the integer ,i2))))
+(define-syntax (logop.logbitp-integer i1 i2)
+ `(the integer (lisp:logbitp (the fixnum ,i1) (the integer ,i2))))
+(define-syntax (logop.ash-integer i1 i2)
+ `(the integer (lisp:ash (the integer ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logcount-integer i1)
+ `(the fixnum (lisp:logcount (the integer ,i1))))
+(define-syntax (logop.integer-length-integer i1)
+ `(the fixnum (lisp:integer-length (the integer ,i1))))
+
+
+;;; Fixnum operations
+
+(define-syntax (logop.logior-int i1 i2)
+ `(the fixnum (lisp:logior (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logxor-int i1 i2)
+ `(the fixnum (lisp:logxor (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logand-int i1 i2)
+ `(the fixnum (lisp:logand (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logeqv-int i1 i2)
+ `(the fixnum (lisp:logeqv (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.lognand-int i1 i2)
+ `(the fixnum (lisp:lognand (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.lognor-int i1 i2)
+ `(the fixnum (lisp:lognor (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logandc1-int i1 i2)
+ `(the fixnum (lisp:logandc1 (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logandc2-int i1 i2)
+ `(the fixnum (lisp:logandc2 (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logorc1-int i1 i2)
+ `(the fixnum (lisp:logorc1 (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logorc2-int i1 i2)
+ `(the fixnum (lisp:logorc2 (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.lognot-int i1)
+ `(the fixnum (lisp:lognot (the fixnum ,i1))))
+(define-syntax (logop.logtest-int i1 i2)
+ `(the fixnum (lisp:logtest (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logbitp-int i1 i2)
+ `(the fixnum (lisp:logbitp (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.ash-int i1 i2)
+ `(the fixnum (lisp:ash (the fixnum ,i1) (the fixnum ,i2))))
+(define-syntax (logop.logcount-int i1)
+ `(the fixnum (lisp:logcount (the fixnum ,i1))))
+(define-syntax (logop.integer-length-int i1)
+ `(the fixnum (lisp:integer-length (the fixnum ,i1))))
+
+
+
diff --git a/progs/lib/cl/logop.hs b/progs/lib/cl/logop.hs
new file mode 100644
index 0000000..1d0f9ba
--- /dev/null
+++ b/progs/lib/cl/logop.hs
@@ -0,0 +1,63 @@
+-- logop.hs -- logical operations on numbers
+--
+-- author : Sandra Loosemore
+-- date : 19 June 1993
+--
+
+module LogOp where
+
+import LogOpPrims -- from logop-prims.hi
+
+class LogOperand a where
+ logior :: a -> a -> a
+ logxor :: a -> a -> a
+ logand :: a -> a -> a
+ logeqv :: a -> a -> a
+ lognand :: a -> a -> a
+ lognor :: a -> a -> a
+ logandc1 :: a -> a -> a
+ logandc2 :: a -> a -> a
+ logorc1 :: a -> a -> a
+ logorc2 :: a -> a -> a
+ lognot :: a -> a
+ logtest :: a -> a -> a
+ logbitp :: Int -> a -> a
+ ash :: a -> Int -> a
+ logcount :: a -> Int
+ integerLength :: a -> Int
+
+instance LogOperand Integer where
+ logior = logiorInteger
+ logxor = logxorInteger
+ logand = logandInteger
+ logeqv = logeqvInteger
+ lognand = lognandInteger
+ lognor = lognorInteger
+ logandc1 = logandc1Integer
+ logandc2 = logandc2Integer
+ logorc1 = logorc1Integer
+ logorc2 = logorc2Integer
+ lognot = lognotInteger
+ logtest = logtestInteger
+ logbitp = logbitpInteger
+ ash = ashInteger
+ logcount = logcountInteger
+ integerLength = integerLengthInteger
+
+instance LogOperand Int where
+ logior = logiorInt
+ logxor = logxorInt
+ logand = logandInt
+ logeqv = logeqvInt
+ lognand = lognandInt
+ lognor = lognorInt
+ logandc1 = logandc1Int
+ logandc2 = logandc2Int
+ logorc1 = logorc1Int
+ logorc2 = logorc2Int
+ lognot = lognotInt
+ logtest = logtestInt
+ logbitp = logbitpInt
+ ash = ashInt
+ logcount = logcountInt
+ integerLength = integerLengthInt
diff --git a/progs/lib/cl/logop.hu b/progs/lib/cl/logop.hu
new file mode 100644
index 0000000..cfe8209
--- /dev/null
+++ b/progs/lib/cl/logop.hu
@@ -0,0 +1,5 @@
+:output $LIBRARYBIN/
+:o= all
+logop.hs
+logop-prims.scm
+logop-prims.hi
diff --git a/progs/lib/cl/maybe.hs b/progs/lib/cl/maybe.hs
new file mode 100644
index 0000000..8ce01e5
--- /dev/null
+++ b/progs/lib/cl/maybe.hs
@@ -0,0 +1,12 @@
+-- maybe.hs -- "maybe" type
+--
+-- author : Sandra Loosemore
+-- date : 22 June 1993
+--
+
+module Maybe where
+
+data Maybe a = Some a | Null
+
+{-# ImportLispType (Maybe(Some("identity", "identity", "identity"),
+ Null("not", "'#f"))) #-}
diff --git a/progs/lib/cl/maybe.hu b/progs/lib/cl/maybe.hu
new file mode 100644
index 0000000..2115c71
--- /dev/null
+++ b/progs/lib/cl/maybe.hu
@@ -0,0 +1,3 @@
+:output $LIBRARYBIN/
+:o= all
+maybe.hs
diff --git a/progs/lib/cl/random-prims.hi b/progs/lib/cl/random-prims.hi
new file mode 100644
index 0000000..e66d802
--- /dev/null
+++ b/progs/lib/cl/random-prims.hi
@@ -0,0 +1,20 @@
+-- random-prims.hi -- interface file to random number primitives
+--
+-- author : Sandra Loosemore
+-- date : 22 June 1993
+--
+
+
+interface RandomPrims where
+
+randomInt :: Int -> IO Int
+randomInteger :: Integer -> IO Integer
+randomFloat :: Float -> IO Float
+randomDouble :: Double -> IO Double
+
+{-#
+randomInt :: LispName("lisp:random"), Complexity(5)
+randomInteger :: LispName("lisp:random"), Complexity(5)
+randomFloat :: LispName("lisp:random"), Complexity(5)
+randomDouble :: LispName("lisp:random"), Complexity(5)
+#-}
diff --git a/progs/lib/cl/random.hs b/progs/lib/cl/random.hs
new file mode 100644
index 0000000..93d26e4
--- /dev/null
+++ b/progs/lib/cl/random.hs
@@ -0,0 +1,21 @@
+-- random.hs -- random number functions
+--
+-- author : Sandra Loosemore
+-- date : 22 June 1993
+--
+
+module Random where
+
+import RandomPrims -- from random-prims.hi
+
+class RandomOperand a where
+ random :: a -> IO a
+
+instance RandomOperand Int where
+ random = randomInt
+instance RandomOperand Integer where
+ random = randomInteger
+instance RandomOperand Float where
+ random = randomFloat
+instance RandomOperand Double where
+ random = randomDouble
diff --git a/progs/lib/cl/random.hu b/progs/lib/cl/random.hu
new file mode 100644
index 0000000..4b8e286
--- /dev/null
+++ b/progs/lib/cl/random.hu
@@ -0,0 +1,4 @@
+:output $LIBRARYBIN/
+:o= all
+random.hs
+random-prims.hi