deftype Questions

1

Solved

I am a bit new to the CL type system but I thought something like the following could work. (deftype list-of (type) `(labels ((check-all (l) (every (lambda (item) (typep item ,type)) l))) (and...
Barret asked 22/3, 2023 at 20:40

2

Solved

I'm trying out Clojure 1.2, specifically mutable fields which are supported in deftype according to the clojure.org documentation. But I can't get the set to work. What is the syntax for updating...
Nonunion asked 28/6, 2010 at 13:52

2

I'd like to be able to use a defined type as a parameter specializer to a defmethod. The motivation is readability and flexibility to change at a later stage. Somehting like this: (deftype foo () ...
Tiatiana asked 26/4, 2015 at 12:8

2

Solved

I have a project set up with leiningen called techne. I created a module called scrub with a type in it called Scrub and a function called foo. techne/scrub.clj: (ns techne.scrub) (deftype Scrub...
Demimonde asked 11/9, 2010 at 11:22

1

Solved

I want to implement transient and persistent! in my Clojure deftype. As far as I can tell, this means having another deftype, TransientMyThing, implement the necessary methods. Okay so far, but tho...
Plumbic asked 19/6, 2011 at 1:51

1

Solved

EDIT: After posting the previous version of my question I discovered that the real problem is with nested functions. If I have a closure within a deftype I can not update any mutable fields from w...
Commercialize asked 14/8, 2013 at 15:41

1

Solved

As an exercise, I am developing a data structure similar to Vector. I have implemented all interfaces which IPersistentVector extends, but I have not found the interface where 'conj' is defined. Wh...
Simas asked 8/1, 2012 at 20:51

1

Solved

I'm curious as to how to do a Clojure deftype that contains a reference to itself, e.g. (deftype BinaryTree [^BinaryTree left ^BinaryTree right]) This doesn't work... however I see no intrinsic...
Monaco asked 27/1, 2011 at 14:17

2

Solved

(deftype Bag [state] Object (toString [bag] (str "Bag???" state))) I want the toString to look something like clojure.core=> (def b (Bag. {:apples 1 :bannanas 4})) #'clojure.core/b clojur...
Overcapitalize asked 10/9, 2010 at 22:41

1

Solved

I am trying to use clojure in a compiler and thus need to parameterize calls to deftype; however, I am having difficulty making the type hints carry through. Consider the following code: (defn des...
Bybee asked 25/7, 2010 at 19:22

1

Solved

I'm trying to create a new type in Clojure using deftype to implement a two dimensional (x,y) coordinate, which implements a "Location" protocol. I'd also like to have this implement the standard ...
Americium asked 10/6, 2010 at 20:46

1

Solved

I'm attempting to use deftype (from the bleeding-edge clojure 1.2 branch) to create a java class that implements the java Servlet interface. I would expect the code below to compile (even though it...
Ereshkigal asked 18/5, 2010 at 1:22

1

Solved

Clojure structs can be arbitrarily extended, adding new fields. Is it possible to extend types (created using deftype) in a similar way? EDIT: For the benefit future visitors, as Brian pointed o...
Hurtle asked 19/3, 2010 at 5:41

1

Solved

Yesterday, Rich pulled the 'new' branch of Clojure into master. We are now embracing the beauty that is deftype and defprotocol. Of course, I, coming from Haskell, am very tempted to define types l...
Cinnabar asked 12/1, 2010 at 10:38

2

Solved

In clojure, how do I type type hint a type that I have created? (I want to nest the types.) e.g. I had thought that this would work: (deftype A [#^somePrimitive someField]) (deftype B [#^A Av...
Withdrawn asked 29/12, 2009 at 19:27
1

© 2022 - 2024 — McMap. All rights reserved.