Add some more calls to implement to make tests pass

This commit is contained in:
Scott Olsen 2020-05-10 13:32:22 -04:00
parent e6f8f3aff1
commit f13a2fdd9d
20 changed files with 117 additions and 12 deletions

View File

@ -105,6 +105,7 @@ Returns `Nothing` if the array is empty.")
(set! eq false) (set! eq false)
(break)))) (break))))
eq))) eq)))
(implements = Array.=)
(doc maximum "gets the maximum in an array (elements must support `<`) and wraps it in a `Just`. (doc maximum "gets the maximum in an array (elements must support `<`) and wraps it in a `Just`.
@ -144,6 +145,7 @@ If the array is empty, returns `Nothing`")
(for [i start-index end-index] (for [i start-index end-index]
(set! result (push-back result @(unsafe-nth xs i)))) (set! result (push-back result @(unsafe-nth xs i))))
result)) result))
(implements slice Array.slice)
(doc prefix "gets a prefix array to `end-index`.") (doc prefix "gets a prefix array to `end-index`.")
(defn prefix [xs end-index] (defn prefix [xs end-index]

View File

@ -13,6 +13,8 @@
(defmodule RefBool (defmodule RefBool
(defn = [a b] (defn = [a b]
(Bool.= @a @b))) (Bool.= @a @b))
(implements = RefBool.=)
)
(defn not [a] (Bool.not a)) (defn not [a] (Bool.not a))

View File

@ -58,11 +58,15 @@
(defmodule CharRef (defmodule CharRef
(defn = [a b] (defn = [a b]
(Char.= @a @b)) (Char.= @a @b))
(implements = CharRef.=)
(defn < [a b] (defn < [a b]
(Char.< @a @b)) (Char.< @a @b))
(implements < CharRef.<)
(defn > [a b] (defn > [a b]
(Char.> @a @b)) (Char.> @a @b))
(implements > CharRef.>)
) )
(defmodule PtrChar (defmodule PtrChar
(register str (Fn [(Ptr Char)] String))) (register str (Fn [(Ptr Char)] String))
(implements str PtrChar.str))

View File

@ -1,5 +1,9 @@
(definterface unsafe-nth (Fn [(Ref (a b) c) Int] &b)) (definterface unsafe-nth (Fn [(Ref (a b) c) Int] &b))
(implements unsafe-nth Array.unsafe-nth)
(implements unsafe-nth StaticArray.unsafe-nth)
(definterface length (Fn [(Ref (a b))] Int)) (definterface length (Fn [(Ref (a b))] Int))
(implements unsafe-nth Array.length)
(implements unsafe-nth StaticArray.length)
(defmodule Collections (defmodule Collections
(defn empty? [a] (defn empty? [a]

View File

@ -27,8 +27,10 @@
(use Id) (use Id)
(defn hash [k] (defn hash [k]
(get-tag k)) (get-tag k))
(implements hash Color.hash)
(defn = [a b] (defn = [a b]
(= (hash (the (Ref Id) a)) (hash b))) (= (hash (the (Ref Id) a)) (hash b)))
(implements = Color.=)
(def table (def table
{(Black) @"30" {(Black) @"30"

View File

@ -68,7 +68,8 @@
(implements floor Double.floor) (implements floor Double.floor)
(implements frexp Double.frexp) (implements frexp Double.frexp)
(implements ldexp Double.ldexp) (implements ldexp Double.ldexp)
(implements log Double.log10) (implements log Double.log)
(implements log10 Double.log10)
(implements mod Double.mod) (implements mod Double.mod)
(implements modf Double.modf) (implements modf Double.modf)
(implements pow Double.pow) (implements pow Double.pow)
@ -95,7 +96,7 @@ The margin of error is `0.00001`.")
(defn dec [x] (defn dec [x]
(- x 1.0)) (- x 1.0))
(implements inc Double.dec) (implements dec Double.dec)
(defn add-ref [x y] (defn add-ref [x y]
(Double.+ @x @y)) (Double.+ @x @y))
@ -105,10 +106,13 @@ The margin of error is `0.00001`.")
(defmodule DoubleRef (defmodule DoubleRef
(defn = [a b] (defn = [a b]
(Double.= @a @b)) (Double.= @a @b))
(implements = DoubleRef.=)
(defn < [a b] (defn < [a b]
(Double.< @a @b)) (Double.< @a @b))
(implements < DoubleRef.<)
(defn > [a b] (defn > [a b]
(Double.> @a @b)) (Double.> @a @b))
(implements > DoubleRef.>)
) )

View File

@ -79,7 +79,8 @@ The margin of error is 0.00001.")
(implements floor Float.floor) (implements floor Float.floor)
(implements frexp Float.frexp) (implements frexp Float.frexp)
(implements ldexp Float.ldexp) (implements ldexp Float.ldexp)
(implements log Float.log10) (implements log Float.log)
(implements log10 Float.log10)
(implements mod Float.mod) (implements mod Float.mod)
(implements modf Float.modf) (implements modf Float.modf)
(implements pow Float.pow) (implements pow Float.pow)

View File

@ -95,10 +95,13 @@
(defmodule IntRef (defmodule IntRef
(defn = [a b] (defn = [a b]
(Int.= @a @b)) (Int.= @a @b))
(implements = IntRef.=)
(defn < [a b] (defn < [a b]
(Int.< @a @b)) (Int.< @a @b))
(implements < IntRef.<)
(defn > [a b] (defn > [a b]
(Int.> @a @b)) (Int.> @a @b))
(implements > IntRef.>)
) )

View File

@ -11,66 +11,82 @@
(set! a (* a b)) (set! a (* a b))
(set! x (Int.inc x)))) (set! x (Int.inc x))))
(Int.abs vh))) (Int.abs vh)))
(implements hash String.hash)
) )
(defmodule Int (defmodule Int
(defn hash [k] (the Int @k)) (defn hash [k] (the Int @k))
(implements hash Int.hash)
) )
(defmodule Long (defmodule Long
(defn hash [k] (to-int (the Long @k))) (defn hash [k] (to-int (the Long @k)))
(implements hash Long.hash)
) )
(defmodule Bool (defmodule Bool
(defn hash [k] (if (the Bool @k) 1 0)) (defn hash [k] (if (the Bool @k) 1 0))
(implements hash Bool.hash)
) )
(defmodule Char (defmodule Char
(defn hash [k] (to-int (the Char @k))) (defn hash [k] (to-int (the Char @k)))
(implements hash Char.hash)
) )
(defmodule Byte (defmodule Byte
(defn hash [k] (to-int (the Byte @k))) (defn hash [k] (to-int (the Byte @k)))
(implements hash Byte.hash)
) )
(defmodule Float (defmodule Float
(defn hash [k] (Float.to-bytes @k)) (defn hash [k] (Float.to-bytes @k))
(implements hash Float.hash)
) )
(defmodule Double (defmodule Double
(defn hash [k] (Long.to-int (Double.to-bytes @k))) (defn hash [k] (Long.to-int (Double.to-bytes @k)))
(implements hash Double.hash)
) )
(defmodule Int8 (defmodule Int8
(defn hash [k] (Long.to-int (Int8.to-long @k))) (defn hash [k] (Long.to-int (Int8.to-long @k)))
(implements hash Int8.hash)
) )
(defmodule Int16 (defmodule Int16
(defn hash [k] (Long.to-int (Int16.to-long @k))) (defn hash [k] (Long.to-int (Int16.to-long @k)))
(implements hash Int16.hash)
) )
(defmodule Int32 (defmodule Int32
(defn hash [k] (Long.to-int (Int32.to-long @k))) (defn hash [k] (Long.to-int (Int32.to-long @k)))
(implements hash Int32.hash)
) )
(defmodule Int64 (defmodule Int64
(defn hash [k] (Long.to-int (Int64.to-long @k))) (defn hash [k] (Long.to-int (Int64.to-long @k)))
(implements hash Int64.hash)
) )
(defmodule Uint8 (defmodule Uint8
(defn hash [k] (Long.to-int (Uint8.to-long @k))) (defn hash [k] (Long.to-int (Uint8.to-long @k)))
(implements hash Uint8.hash)
) )
(defmodule Uint16 (defmodule Uint16
(defn hash [k] (Long.to-int (Uint16.to-long @k))) (defn hash [k] (Long.to-int (Uint16.to-long @k)))
(implements hash Uint16.hash)
) )
(defmodule Uint32 (defmodule Uint32
(defn hash [k] (Long.to-int (Uint32.to-long @k))) (defn hash [k] (Long.to-int (Uint32.to-long @k)))
(implements hash Uint32.hash)
) )
(defmodule Uint64 (defmodule Uint64
(defn hash [k] (Long.to-int (Uint64.to-long @k))) (defn hash [k] (Long.to-int (Uint64.to-long @k)))
(implements hash Uint64.hash)
) )
(defmodule Pair (defmodule Pair
@ -79,6 +95,7 @@
(set! code (+ (* 31 code) (hash (Pair.a pair)))) (set! code (+ (* 31 code) (hash (Pair.a pair))))
(set! code (+ (* 31 code) (hash (Pair.b pair)))) (set! code (+ (* 31 code) (hash (Pair.b pair))))
code)) code))
(implements hash Pair.hash)
) )
(deftype (Bucket a b) [entries (Array (Pair a b))]) (deftype (Bucket a b) [entries (Array (Pair a b))])
@ -261,6 +278,7 @@
(and (= (length m1) (length m2)) (and (= (length m1) (length m2))
;; we could use contains? and get-with-default here to avoid requiring a (zero) for the value type ;; we could use contains? and get-with-default here to avoid requiring a (zero) for the value type
(all? &(fn [k v] (= v &(get m2 k))) m1))) (all? &(fn [k v] (= v &(get m2 k))) m1)))
(implements = Map.=)
(doc for-each "Execute the binary function f for all keys and values in the map m.") (doc for-each "Execute the binary function f for all keys and values in the map m.")
(defn for-each [m f] (defn for-each [m f]
@ -449,6 +467,7 @@
(defn = [set-a set-b] (defn = [set-a set-b]
(and (= (Set.length set-a) (Set.length set-b)) (and (= (Set.length set-a) (Set.length set-b))
(subset? set-a set-b))) (subset? set-a set-b)))
(implements = Set.=)
(doc for-each "Execute the unary function f for each element in the set s.") (doc for-each "Execute the unary function f for each element in the set s.")
(defn for-each [s f] (defn for-each [s f]
@ -507,4 +526,5 @@
@"{" @"{"
set)] set)]
(String.append &res " }"))) (String.append &res " }")))
(implements str Set.str)
) )

View File

@ -51,6 +51,7 @@ It is the inverse of [`just?`](#just?).")
(match-ref b (match-ref b
(Nothing) false (Nothing) false
(Just y) (= x y)))) (Just y) (= x y))))
(implements = Maybe.=)
(doc unsafe-ptr "Creates a `(Ptr a)` from a `(Maybe a)`. If the `Maybe` was (doc unsafe-ptr "Creates a `(Ptr a)` from a `(Maybe a)`. If the `Maybe` was
`Nothing`, this function will return a `NULL` value.") `Nothing`, this function will return a `NULL` value.")
@ -69,4 +70,5 @@ It is the inverse of [`just?`](#just?).")
(doc zero "returns `Nothing`.") (doc zero "returns `Nothing`.")
(defn zero [] (Nothing)) (defn zero [] (Nothing))
(implements zero Maybe.zero)
) )

View File

@ -29,12 +29,16 @@ If you want to replace all occurrences of the pattern, use `-1`.")
(defn matches? [pat s] (/= (find pat s) -1)) (defn matches? [pat s] (/= (find pat s) -1))
(register str (Fn [&Pattern] String)) (register str (Fn [&Pattern] String))
(implements str Pattern.str)
(register prn (Fn [&Pattern] String)) (register prn (Fn [&Pattern] String))
(implements prn Pattern.prn)
(register init (Fn [&String] Pattern)) (register init (Fn [&String] Pattern))
(register = (Fn [&Pattern &Pattern] Bool)) (register = (Fn [&Pattern &Pattern] Bool))
(implements = Pattern.=)
(register delete (Fn [Pattern] ())) (register delete (Fn [Pattern] ()))
(register copy (Fn [&Pattern] Pattern)) (register copy (Fn [&Pattern] Pattern))
(implements copy Pattern.copy)
(doc from-chars "creates a pattern that matches a group of characters from a list of those characters.") (doc from-chars "creates a pattern that matches a group of characters from a list of those characters.")
(defn from-chars [chars] (defn from-chars [chars]

View File

@ -1,4 +1,6 @@
(defmodule Pointer (defmodule Pointer
(defn inc [a] (Pointer.add a 1l)) (defn inc [a] (Pointer.add a 1l))
(implements inc Pointer.inc)
(defn dec [a] (Pointer.sub a 1l)) (defn dec [a] (Pointer.sub a 1l))
(implements dec Pointer.dec)
) )

View File

@ -106,6 +106,7 @@ It is the inverse of [`success?`](#success?).")
(match-ref b (match-ref b
(Success _) false (Success _) false
(Error y) (= x y)))) (Error y) (= x y))))
(implements = Result.=)
) )
(defmodule Maybe (defmodule Maybe

View File

@ -50,6 +50,9 @@
(defn prn [a] (Int8.prn @a)) (defn prn [a] (Int8.prn @a))
(defn str [a] (Int8.str @a)) (defn str [a] (Int8.str @a))
(defn = [a b] (Int8.= @a @b)) (defn = [a b] (Int8.= @a @b))
(implements prn Int8Extra.prn)
(implements str Int8Extra.str)
(implements = Int8Extra.=)
) )
(defmodule Int16 (defmodule Int16
@ -93,6 +96,9 @@
(defn prn [a] (Int16.prn @a)) (defn prn [a] (Int16.prn @a))
(defn str [a] (Int16.str @a)) (defn str [a] (Int16.str @a))
(defn = [a b] (Int16.= @a @b)) (defn = [a b] (Int16.= @a @b))
(implements prn Int16Extra.prn)
(implements str Int16Extra.str)
(implements = Int16Extra.=)
) )
(defmodule Int32 (defmodule Int32
@ -136,6 +142,9 @@
(defn prn [a] (Int32.prn @a)) (defn prn [a] (Int32.prn @a))
(defn str [a] (Int32.str @a)) (defn str [a] (Int32.str @a))
(defn = [a b] (Int32.= @a @b)) (defn = [a b] (Int32.= @a @b))
(implements prn Int32Extra.prn)
(implements str Int32Extra.str)
(implements = Int32Extra.=)
) )
(defmodule Int64 (defmodule Int64
@ -179,6 +188,9 @@
(defn prn [a] (Int64.prn @a)) (defn prn [a] (Int64.prn @a))
(defn str [a] (Int64.str @a)) (defn str [a] (Int64.str @a))
(defn = [a b] (Int64.= @a @b)) (defn = [a b] (Int64.= @a @b))
(implements prn Int64Extra.prn)
(implements str Int64Extra.str)
(implements = Int64Extra.=)
) )
(defmodule Uint8 (defmodule Uint8
@ -222,6 +234,9 @@
(defn prn [a] (Uint8.prn @a)) (defn prn [a] (Uint8.prn @a))
(defn str [a] (Uint8.str @a)) (defn str [a] (Uint8.str @a))
(defn = [a b] (Uint8.= @a @b)) (defn = [a b] (Uint8.= @a @b))
(implements prn Uint8Extra.prn)
(implements str Uint8Extra.str)
(implements = Uint8Extra.=)
) )
(defmodule Uint16 (defmodule Uint16
@ -265,6 +280,9 @@
(defn prn [a] (Uint16.prn @a)) (defn prn [a] (Uint16.prn @a))
(defn str [a] (Uint16.str @a)) (defn str [a] (Uint16.str @a))
(defn = [a b] (Uint16.= @a @b)) (defn = [a b] (Uint16.= @a @b))
(implements prn Uint16Extra.prn)
(implements str Uint16Extra.str)
(implements = Uint16Extra.=)
) )
(defmodule Uint32 (defmodule Uint32
@ -308,6 +326,9 @@
(defn prn [a] (Uint32.prn @a)) (defn prn [a] (Uint32.prn @a))
(defn str [a] (Uint32.str @a)) (defn str [a] (Uint32.str @a))
(defn = [a b] (Uint32.= @a @b)) (defn = [a b] (Uint32.= @a @b))
(implements prn Uint32Extra.prn)
(implements str Uint32Extra.str)
(implements = Uint32Extra.=)
) )
(defmodule Uint64 (defmodule Uint64
@ -351,4 +372,7 @@
(defn prn [a] (Uint64.prn @a)) (defn prn [a] (Uint64.prn @a))
(defn str [a] (Uint64.str @a)) (defn str [a] (Uint64.str @a))
(defn = [a b] (Uint64.= @a @b)) (defn = [a b] (Uint64.= @a @b))
(implements prn Uint64Extra.prn)
(implements str Uint64Extra.str)
(implements = Uint64Extra.=)
) )

View File

@ -20,6 +20,7 @@
(register from-chars (Fn [&(Array Char)] String)) (register from-chars (Fn [&(Array Char)] String))
(register tail (λ [(Ref String)] String)) (register tail (λ [(Ref String)] String))
(register format (Fn [&String &String] String)) (register format (Fn [&String &String] String))
(implements format String.format)
(register string-set! (Fn [&String Int Char] ())) (register string-set! (Fn [&String Int Char] ()))
(register string-set-at! (Fn [&String Int &String] ())) (register string-set-at! (Fn [&String Int &String] ()))
(register allocate (Fn [Int Char] String)) (register allocate (Fn [Int Char] String))
@ -171,14 +172,15 @@
(defn < [a b] (defn < [a b]
(String.< &a &b)) (String.< &a &b))
(implements = StringCopy.<) (implements < StringCopy.<)
(defn > [a b] (defn > [a b]
(String.> &a &b)) (String.> &a &b))
(implements = StringCopy.>) (implements > StringCopy.>)
(defn prn [s] (defn prn [s]
(prn &(the String s))) (prn &(the String s)))
(implements prn StringCopy.prn)
(defn str [s] (defn str [s]
(str &(the String s))) (str &(the String s)))
@ -187,12 +189,14 @@
(defmodule Bool (defmodule Bool
(register str (Fn [Bool] String)) (register str (Fn [Bool] String))
(implements str Bool.str)
(register format (Fn [&String Bool] String)) (register format (Fn [&String Bool] String))
(implements format Bool.format) (implements format Bool.format)
) )
(defmodule Int (defmodule Int
(register str (Fn [Int] String)) (register str (Fn [Int] String))
(implements str Int.str)
(register format (Fn [&String Int] String)) (register format (Fn [&String Int] String))
(implements format Int.format) (implements format Int.format)
(register from-string (λ [&String] Int)) (register from-string (λ [&String] Int))
@ -201,6 +205,7 @@
(defmodule Byte (defmodule Byte
(register str (Fn [Byte] String)) (register str (Fn [Byte] String))
(implements str Byte.str)
(register format (Fn [&String Byte] String)) (register format (Fn [&String Byte] String))
(implements format Byte.format) (implements format Byte.format)
(register from-string (λ [&String] Byte)) (register from-string (λ [&String] Byte))
@ -209,6 +214,7 @@
(defmodule Float (defmodule Float
(register str (Fn [Float] String)) (register str (Fn [Float] String))
(implements str Float.str)
(register format (Fn [&String Float] String)) (register format (Fn [&String Float] String))
(implements format Float.format) (implements format Float.format)
(register from-string (λ [&String] Float)) (register from-string (λ [&String] Float))
@ -217,6 +223,7 @@
(defmodule Long (defmodule Long
(register str (Fn [Long] String)) (register str (Fn [Long] String))
(implements str Long.str)
(register format (Fn [&String Long] String)) (register format (Fn [&String Long] String))
(implements format Long.format) (implements format Long.format)
(register from-string (λ [&String] Long)) (register from-string (λ [&String] Long))
@ -225,6 +232,7 @@
(defmodule Double (defmodule Double
(register str (Fn [Double] String)) (register str (Fn [Double] String))
(implements str Double.str)
(register format (Fn [&String Double] String)) (register format (Fn [&String Double] String))
(implements format Double.format) (implements format Double.format)
(register from-string (λ [&String] Double)) (register from-string (λ [&String] Double))
@ -233,6 +241,7 @@
(defmodule Char (defmodule Char
(register str (Fn [Char] String)) (register str (Fn [Char] String))
(implements str Char.str)
(register prn (Fn [Char] String)) (register prn (Fn [Char] String))
(implements prn Char.prn) (implements prn Char.prn)
(register format (Fn [&String Char] String)) (register format (Fn [&String Char] String))
@ -245,17 +254,21 @@
(defn prn [x] (Int.str @x)) (defn prn [x] (Int.str @x))
(implements prn IntRef.prn) (implements prn IntRef.prn)
(defn str [x] (Int.str @x)) (defn str [x] (Int.str @x))
(implements str IntRef.str)
) )
(defmodule BoolRef (defmodule BoolRef
(defn prn [x] (Bool.str @x)) (defn prn [x] (Bool.str @x))
(implements prn BoolRef.prn) (implements prn BoolRef.prn)
(defn str [x] (Bool.str @x))) (defn str [x] (Bool.str @x))
(implements str BoolRef.str)
)
(defmodule ByteRef (defmodule ByteRef
(defn prn [x] (Byte.str @x)) (defn prn [x] (Byte.str @x))
(implements prn ByteRef.prn) (implements prn ByteRef.prn)
(defn str [x] (Byte.str @x)) (defn str [x] (Byte.str @x))
(implements str ByteRef.str)
) )
(defmodule Long (defn prn [x] (Long.str x)) (implements prn Long.prn)) (defmodule Long (defn prn [x] (Long.str x)) (implements prn Long.prn))

View File

@ -4,14 +4,17 @@
(defn = [p1 p2] (defn = [p1 p2]
(and (= (Pair.a p1) (Pair.a p2)) (and (= (Pair.a p1) (Pair.a p2))
(= (Pair.b p1) (Pair.b p2)))) (= (Pair.b p1) (Pair.b p2))))
(implements = PairRef.=)
(defn < [p1 p2] (defn < [p1 p2]
(if (= (Pair.a p1) (Pair.a p2)) (if (= (Pair.a p1) (Pair.a p2))
(< (Pair.b p1) (Pair.b p2)) (< (Pair.b p1) (Pair.b p2))
(< (Pair.a p1) (Pair.a p2)))) (< (Pair.a p1) (Pair.a p2))))
(implements < PairRef.<)
(defn > [p1 p2] (defn > [p1 p2]
(PairRef.< p2 p1))) (PairRef.< p2 p1)))
(implements > PairRef.=)
(defmodule Pair (defmodule Pair
(defn init-from-refs [r1 r2] (defn init-from-refs [r1 r2]
@ -20,12 +23,15 @@
(defn = [p1 p2] (defn = [p1 p2]
(and (= (Pair.a &p1) (Pair.a &p2)) (and (= (Pair.a &p1) (Pair.a &p2))
(= (Pair.b &p1) (Pair.b &p2)))) (= (Pair.b &p1) (Pair.b &p2))))
(implements = Pair.=)
(defn < [p1 p2] (defn < [p1 p2]
(PairRef.< &p1 &p2)) (PairRef.< &p1 &p2))
(implements < Pair.<)
(defn > [p1 p2] (defn > [p1 p2]
(PairRef.> &p1 &p2)) (PairRef.> &p1 &p2))
(implements > Pair.>)
(doc reverse "reverses a `Pair` `p` such that its first member is its second member and vice versa.") (doc reverse "reverses a `Pair` `p` such that its first member is its second member and vice versa.")
(defn reverse [p] (defn reverse [p]

View File

@ -7,13 +7,15 @@
(defmodule ArrayExtension (defmodule ArrayExtension
(defn fmap [f a] (Array.endo-map f a)) (defn fmap [f a] (Array.endo-map f a))
(implements fmap ArrayExtension.fmap)
) )
(deftype Box [x Int]) (deftype Box [x Int])
(defmodule Box (defmodule Box
(defn fmap [f box] (let [new-x (~f @(Box.x &box))] (defn fmap [f box] (let [new-x (~f @(Box.x &box))]
(Box.set-x box new-x)))) (Box.set-x box new-x)))
(implements fmap Box.fmap))
(use Box) (use Box)
(use ArrayExtension) (use ArrayExtension)

View File

@ -9,7 +9,12 @@
(defn > [a b] (defn > [a b]
(> (Age.x a) (Age.x b))) (> (Age.x a) (Age.x b)))
(defn < [a b] (defn < [a b]
(< (Age.x a) (Age.x b)))) (< (Age.x a) (Age.x b)))
(implements = Age.=)
(implements > Age.>)
(implements < Age.<)
)
(defn main [] (defn main []
(let-do [ints (Array.sort [10 3 75 40]) (let-do [ints (Array.sort [10 3 75 40])

View File

@ -291,9 +291,11 @@
(defn < [a b] (defn < [a b]
(< (Array.length a) (< (Array.length a)
(Array.length b))) (Array.length b)))
(implements < ArrayCompareExtension.<)
(defn > [a b] (defn > [a b]
(> (Array.length a) (> (Array.length a)
(Array.length b)))) (Array.length b))))
(implements > ArrayCompareExtension.>)
(defn array-sort-1 [] (defn array-sort-1 []
(let [xs [[0 0] [0 0 0] [0 0 0 0] [0]] (let [xs [[0 0] [0 0 0] [0 0 0 0] [0]]
ys (Array.sort xs)] ys (Array.sort xs)]

View File

@ -15,11 +15,13 @@
;; A function with correct nr of args but just generic types used to really confuse the type checker: ;; A function with correct nr of args but just generic types used to really confuse the type checker:
(defmodule Confuse (defmodule Confuse
(defn = [a b] (defn = [a b]
true)) true)
(implements = Confuse.=))
(defmodule Young (defmodule Young
(defn = [y1 y2] (defn = [y1 y2]
(Int.= @(age y1) @(age y2)))) (Int.= @(age y1) @(age y2)))
(implements = Young.=))
;; Now I want to use 'Young.=' in with 'Ur.compare' ;; Now I want to use 'Young.=' in with 'Ur.compare'
(defn f [] (defn f []