Skip to content

Instantly share code, notes, and snippets.

@c-spencer
Last active December 22, 2015 20:48
Show Gist options
  • Save c-spencer/6528482 to your computer and use it in GitHub Desktop.
Save c-spencer/6528482 to your computer and use it in GitHub Desktop.
core.typed messings about
; trying to work around no update-in type
(defmacro typed-update-in [m [v] f]
`((ann-form update-in
(~'All [~'x ~'y]
[ (~'HMap :mandatory {~v ~'x}) (~'Vector* Keyword) [~'x ~'-> ~'y]
~'->
(~'HMap :mandatory {~v ~'y}) ]))
~m [~v] ~f))
; still causes an error because of the inner un-typed update-in
; alternative approach:
(defmacro my-update-in [o k f]
`(assoc ~o ~k (-> ~o ~k ~f)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment