Brendan Tobolaski
2015-08-27 13:50:18 UTC
Apologies in advance if this has a very obvious solution.
I'm trying to annotate Cats' Either monad
<http://funcool.github.io/cats/latest/#_either>. I think I have correct
annotations for both of the records
(t/ann-record [[a :variance :covariant]]
cats.monad.either.Left
[v :- a])
(t/ann-record [[a :variance :covariant]]
cats.monad.either.Right
[v :- a])
My goal is make these usable like the build in types, i.e. I'd like to be
able to annotate the constructors like this:
(t/ann cats.monad.either.left
[a -> (cats.monad.either.Left a)])
(t/ann cats.monad.either.right
[a -> (cats.monad.either.Right a)])
Obviously I'm missing something there as all I get is an unresolved var a.
Maybe what I'm missing is a (t/All [a] ...) but I'm not really sure. Even
if that is correct, I'm not sure what I need to do to allow me to annotate
functions like this
(t/ann collect-successfull
[(t/U (cats.monad.either.Left String)
(cats.monad.either.Right (t/Vec String))) -> (t/Vec String)])
(t/ann try-read
[String -> (t/U (cats.monad.either.Left String)
(cats.monad.either.Right (t/HMap ...)))])
I'm very much a beginner at this as you can probably tell. I've spent some
time digging through the documentation and source code and I'm at a loss
for how to do this. Any help would be greatly appreciated.
I'm trying to annotate Cats' Either monad
<http://funcool.github.io/cats/latest/#_either>. I think I have correct
annotations for both of the records
(t/ann-record [[a :variance :covariant]]
cats.monad.either.Left
[v :- a])
(t/ann-record [[a :variance :covariant]]
cats.monad.either.Right
[v :- a])
My goal is make these usable like the build in types, i.e. I'd like to be
able to annotate the constructors like this:
(t/ann cats.monad.either.left
[a -> (cats.monad.either.Left a)])
(t/ann cats.monad.either.right
[a -> (cats.monad.either.Right a)])
Obviously I'm missing something there as all I get is an unresolved var a.
Maybe what I'm missing is a (t/All [a] ...) but I'm not really sure. Even
if that is correct, I'm not sure what I need to do to allow me to annotate
functions like this
(t/ann collect-successfull
[(t/U (cats.monad.either.Left String)
(cats.monad.either.Right (t/Vec String))) -> (t/Vec String)])
(t/ann try-read
[String -> (t/U (cats.monad.either.Left String)
(cats.monad.either.Right (t/HMap ...)))])
I'm very much a beginner at this as you can probably tell. I've spent some
time digging through the documentation and source code and I'm at a loss
for how to do this. Any help would be greatly appreciated.