Artyom,
(provide/contract
[interp (- AE? number?)])
;; interpret an arithmetical expression yielding a number
(define (interp exp)
;; type-case is very much like a case ... of in Haskell/ML
(type-case AE exp
(num (n) n)
(plus (l r) (+ (interp l) (interp r)))
(sub (l
Hi,
On Sat, Sep 26, 2009 at 3:36 PM, Daniel Werner
daniel.d.wer...@googlemail.com wrote:
On Sep 24, 10:14 am, Miron Brezuleanu mbr...@gmail.com wrote:
about). The degree of typing can be varied (i.e. a person is any map
with a :name key, or any map with only a :name key, or any map with a
On Sep 24, 10:14 am, Miron Brezuleanu mbr...@gmail.com wrote:
about). The degree of typing can be varied (i.e. a person is any map
with a :name key, or any map with only a :name key, or any map with a
:name key which is nil or string etc.)
You may be interested in Konrad Hinsen's (algebraic)
Ooops, sent it to the wrong address.
-- Forwarded message --
From: Artyom Shalkhakov artyom.shalkha...@gmail.com
Date: 2009/9/25
Subject: Re: Schema for data structures
To: clojure group nore...@googlegroups.com
Hello Miron,
is there a way to check if a data structure
One of the things I'm doing in my application is I modified clj-record
to attach metadata about the record's type to each record when find-
records is used. I am then able to have a function that checks that
metadata which can be used as a predicate.
It gets even better because I can then
Hi,
thanks for the suggestions about writing an alternate defstruct. I
tried to turn the wishful thinking from my initial email into code.
Results here:
http://github.com/mbrezu/beak-check
Testing structures with beak-check requires some code, but it allows
to test nested structures and
Hello,
is there a way to check if a data structure complies to a given
schema? (e.g. people is a vector of persons).
I'm using C# a lot and maybe the static typing has changed the way I
think. I feel like adding type checks in unit tests and being able
to say something like:
(is-type (people
You might be looking for the instance? function. It can be used to
determine if something is an instance of a particular class.
user= (instance? java.lang.Integer 5)
true
user= (instance? java.lang.Integer 5)
false
To apply that to a data structure, you'd need to walk your structure
and compare
Hello,
On Thu, Sep 24, 2009 at 5:09 PM, tmountain tinymount...@gmail.com wrote:
To apply that to a data structure, you'd need to walk your structure
and compare the elements contained within against the desired type.
Depending on the structure, you could do something similar to this.
(defn
On Sep 24, 10:59 am, Miron Brezuleanu mbr...@gmail.com wrote:
Well, I only want to enforce duck-typing :-) - for instance, make sure
via unit tests that a function that should return a data structure
with certain properties always returns such a data structure.
Not exactly what you asked for,
Use it just like you use defstruct, e.g.: (defstruct* person :first-
name :last-name :age), but it will also create a little type-checker
function: is-person? Here are some tests to see how it works:
Note that your type checker will give false positives if you're
intending to use accessors:
11 matches
Mail list logo