Skip to content

Commit

Permalink
deftype+ => deftype
Browse files Browse the repository at this point in the history
  • Loading branch information
darkleaf committed Sep 12, 2019
1 parent 49cf1c4 commit 19ecca4
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 32 deletions.
5 changes: 2 additions & 3 deletions src/methodical/impl/cache/simple.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"A basic, dumb cache. `SimpleCache` stores cached methods in a simple map of dispatch-value -> effective method; it
offers no facilities to deduplicate identical methods for the same dispatch value. This behaves similarly to the
caching mechanism in vanilla Clojure."
(:require [potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:require [pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.Cache))

(p.types/deftype+ SimpleCache [atomm]
(deftype SimpleCache [atomm]
PrettyPrintable
(pretty [_]
'(simple-cache))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/cache/watching.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
finalized (which, of course, may actually be never -- but worst-case is that some unneeded calls to `clear-cache!`
get made)."
(:require [methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import java.lang.ref.WeakReference
methodical.interface.Cache))

(declare add-watches remove-watches)

(p.types/deftype+ WatchingCache [^Cache cache watch-key refs]
(deftype WatchingCache [^Cache cache watch-key refs]
PrettyPrintable
(pretty [_]
(concat ['watching-cache cache 'watching] refs))
Expand Down
5 changes: 2 additions & 3 deletions src/methodical/impl/combo/clojure.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
(ns methodical.impl.combo.clojure
"Simple method combination strategy that mimics the way vanilla Clojure multimethods combine methods; that is, to say,
not at all. Like vanilla Clojure multimethods, this method combination only supports primary methods."
(:require [potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:require [pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodCombination))

(p.types/deftype+ ClojureMethodCombination []
(deftype ClojureMethodCombination []
PrettyPrintable
(pretty [_]
'(clojure-method-combination))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/combo/clos.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
are ignored. Primary methods and around methods get an implicit `next-method` arg (see Methodical dox for more on
what this means)."
(:require [methodical.impl.combo.common :as combo.common]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodCombination))

Expand Down Expand Up @@ -53,7 +52,7 @@
result)]
(comp apply-afters combined-method))))

(p.types/deftype+ CLOSStandardMethodCombination []
(deftype CLOSStandardMethodCombination []
PrettyPrintable
(pretty [_]
'(clos-method-combination))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/combo/operator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
...)"
(:refer-clojure :exclude [methods])
(:require [methodical.impl.combo.common :as combo.common]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodCombination))

Expand Down Expand Up @@ -152,7 +151,7 @@

;;;; ### `OperatorMethodCombination`

(p.types/deftype+ OperatorMethodCombination [operator-name]
(deftype OperatorMethodCombination [operator-name]
PrettyPrintable
(pretty [_]
(list 'operator-method-combination operator-name))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/combo/threaded.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns methodical.impl.combo.threaded
(:refer-clojure :exclude [methods])
(:require [methodical.impl.combo.common :as combo.common]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodCombination))

Expand Down Expand Up @@ -70,7 +69,7 @@
(apply method (conj butlast* last*)))]))))


(p.types/deftype+ ThreadingMethodCombination [threading-type]
(deftype ThreadingMethodCombination [threading-type]
PrettyPrintable
(pretty [_]
(list 'threading-method-combination threading-type))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/dispatcher/everything.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
(ns methodical.impl.dispatcher.everything
(:require [methodical.impl.dispatcher.common :as dispatcher.common]
[methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.Dispatcher))

(p.types/deftype+ EverythingDispatcher [hierarchy-var prefs]
(deftype EverythingDispatcher [hierarchy-var prefs]
PrettyPrintable
(pretty [_]
(cons
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/dispatcher/standard.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(:refer-clojure :exclude [prefers prefer-method])
(:require [methodical.impl.dispatcher.common :as dispatcher.common]
[methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.Dispatcher))

Expand Down Expand Up @@ -88,7 +87,7 @@
[qualifier (map second pairs)])))


(p.types/deftype+ StandardDispatcher [dispatch-fn hierarchy-var default-value prefs]
(deftype StandardDispatcher [dispatch-fn hierarchy-var default-value prefs]
PrettyPrintable
(pretty [_]
(concat ['standard-dispatcher dispatch-fn]
Expand Down
5 changes: 2 additions & 3 deletions src/methodical/impl/method_table/clojure.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns methodical.impl.method-table.clojure
(:require [potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:require [pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodTable))

(p.types/deftype+ ClojureMethodTable [m]
(deftype ClojureMethodTable [m]
PrettyPrintable
(pretty [_]
(if (seq m)
Expand Down
5 changes: 2 additions & 3 deletions src/methodical/impl/method_table/standard.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns methodical.impl.method-table.standard
(:require [potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:require [pretty.core :refer [PrettyPrintable]])
(:import methodical.interface.MethodTable))

(p.types/deftype+ StandardMethodTable [primary aux]
(deftype StandardMethodTable [primary aux]
PrettyPrintable
(pretty [_]
(cons
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/multifn/cached.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(ns methodical.impl.multifn.cached
(:require [methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import [methodical.interface Cache MultiFnImpl]))

(p.types/deftype+ CachedMultiFnImpl [^MultiFnImpl impl, ^Cache cache]
(deftype CachedMultiFnImpl [^MultiFnImpl impl, ^Cache cache]
PrettyPrintable
(pretty [_]
(list 'cached-multifn-impl impl cache))
Expand Down
7 changes: 3 additions & 4 deletions src/methodical/impl/multifn/standard.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns methodical.impl.multifn.standard
"Standard Methodical MultiFn impl, which "
(:require [methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import [methodical.interface Dispatcher MethodCombination MethodTable MultiFnImpl]))

Expand All @@ -13,9 +12,9 @@
aux-methods (i/matching-aux-methods dispatcher method-table dispatch-value)]
(i/combine-methods method-combination primary-methods aux-methods)))

(p.types/deftype+ StandardMultiFnImpl [^MethodCombination combo
^Dispatcher dispatcher
^MethodTable method-table]
(deftype StandardMultiFnImpl [^MethodCombination combo
^Dispatcher dispatcher
^MethodTable method-table]
PrettyPrintable
(pretty [_]
(list 'standard-multifn-impl combo dispatcher method-table))
Expand Down
3 changes: 1 addition & 2 deletions src/methodical/impl/standard.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns methodical.impl.standard
(:require [methodical.interface :as i]
[potemkin.types :as p.types]
[pretty.core :refer [PrettyPrintable]])
(:import [methodical.interface Dispatcher MethodCombination MethodTable MultiFnImpl]))

Expand All @@ -27,7 +26,7 @@
([^MultiFnImpl impl a b c d & more]
(apply (effective-method impl (.dispatchValue ^Dispatcher (.dispatcher impl) a b c d more)) a b c d more)))

(p.types/deftype+ StandardMultiFn [^MultiFnImpl impl mta]
(deftype StandardMultiFn [^MultiFnImpl impl mta]
PrettyPrintable
(pretty [_]
(list 'multifn impl))
Expand Down

0 comments on commit 19ecca4

Please sign in to comment.