newbie - misunderstanding of defalias

24 views
Skip to first unread message

Colin Yates

unread,
Mar 9, 2015, 1:09:10 PM3/9/15
to clojure-c...@googlegroups.com
So I am trying to define a type for a pair, the first is a boolean the second might be a map, e.g. [true {}].

The following REPL shows my experiments:

(t/defalias BaseValidationSchema
            '[java.lang.Boolean (t/HMap :complete? false)])

=> nil
(t/cf [true {}] BaseValidationSchema)
Type Error (NO_SOURCE_FILE) Internal Error (:<NO LINE>) Wrong number of arguments passed to type function. Expected 1, actual 2: clojure.core.typed/Vec [java.lang.Boolean (clojure.core.typed/HMap :mandatory {})]
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4403)
(t/cf [true {}] '[java.lang.Boolean (t/HMap :complete? false)])
=> [(t/HVec [true (t/HMap :complete? true)]) {:then tt, :else ff}]

(I know that :complete? is false by default but I am being explicit ;)).

Can somebody explain what I am doing wrong please and the right way to do this?

Thanks!

Ambrose Bonnaire-Sergeant

unread,
Mar 9, 2015, 1:11:06 PM3/9/15
to core.typed
That is super weird and probably a bug in upcasting a HVec to a Vec in subtyping.

Colin Yates

unread,
Mar 9, 2015, 1:16:34 PM3/9/15
to clojure-c...@googlegroups.com
I thought I was being a numpty :). Is there a workaround you can think of here?

Shall I raise an issue on github?



On 9 March 2015 at 17:10, Ambrose Bonnaire-Sergeant

Ambrose Bonnaire-Sergeant

unread,
Mar 9, 2015, 1:35:25 PM3/9/15
to core.typed
Please raise an issue on JIRA.

Ambrose Bonnaire-Sergeant

unread,
Mar 9, 2015, 2:02:56 PM3/9/15
to core.typed
Can you post a stack trace?

Colin Yates

unread,
Mar 9, 2015, 2:22:12 PM3/9/15
to clojure-c...@googlegroups.com

Colin Yates

unread,
Mar 9, 2015, 2:24:16 PM3/9/15
to clojure-c...@googlegroups.com
Well, wouldn't you know - I cannot reproduce it now! Not sure where to go from here...
Reply all
Reply to author
Forward
0 new messages