mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-11 20:49:05 +03:00
38 lines
800 B
Plaintext
38 lines
800 B
Plaintext
(use Int)
|
|
(use IO)
|
|
|
|
(load "Test.carp")
|
|
(use Test)
|
|
|
|
;; Ur is created first and will not know about any other modules
|
|
(defmodule Ur
|
|
(defn compare [a b]
|
|
(= a b)))
|
|
|
|
;; Young is created later
|
|
(deftype Young [age Int])
|
|
|
|
;; A function with correct nr of args but just generic types used to really confuse the type checker:
|
|
(defmodule Confuse
|
|
(defn = [a b]
|
|
true))
|
|
|
|
(defmodule Young
|
|
(defn = [y1 y2]
|
|
(Int.= @(age y1) @(age y2)))
|
|
(defn /= [y1 y2]
|
|
(Int.= @(age y1) @(age y2))))
|
|
|
|
;; Now I want to use 'Young.=' in with 'Ur.compare'
|
|
(defn f []
|
|
(Ur.compare &(Young.init 100) &(Young.init 200)))
|
|
|
|
(defn main []
|
|
(with-test test
|
|
(assert-equal test
|
|
false
|
|
(f)
|
|
"interfaces get resolved correctly"
|
|
)
|
|
(print-test-results test)))
|