m***@flow.net
2015-10-22 21:28:47 UTC
Hey Ambrose,
The following is giving me trouble:
(defalias Pair '[String String])
(ann get-second-fails [(t/Vec Pair) -> (t/Seqable String)])
(defn get-second-fails [in]
(map second in))
(ann get-second-works [(t/Vec Pair) -> (t/Seqable String)])
(defn get-second-works [in]
(map (t/fn [i :- Pair] (second i)) in))
In a nutshell, passing the second function directly to map doesn't work - I
have to wrap it in the core.typed function macro.
What's up with that?
Cheers.
(error is:
Type Error (rest_api/types.clj:459:3) Polymorphic function map could not be
applied to arguments:
Polymorphic Variables:
c
a
b
Domains:
[a b ... b -> c] (t/NonEmptySeqable a) (t/NonEmptySeqable b) ... b
[a b ... b -> c] (t/U (Seqable a) nil) (t/U (Seqable b) nil) ... b
Arguments:
(t/All [x] (t/IFn [(t/HSequential [t/Any x t/Any *]) -> x :object {:id 0,
:path [(Nth 1)]}] [(t/Option (t/I (t/CountRange 0 1) (Seqable x))) -> nil]
[(t/I (t/CountRange 2) (Seqable x)) -> x] [(t/Option (Seqable x)) ->
(t/Option x)])) (IPersistentVector Pair)
Ranges:
(t/NonEmptyASeq c)
(t/ASeq c)
with expected type:
(t/Seqable String)
in: (map second in)
The following is giving me trouble:
(defalias Pair '[String String])
(ann get-second-fails [(t/Vec Pair) -> (t/Seqable String)])
(defn get-second-fails [in]
(map second in))
(ann get-second-works [(t/Vec Pair) -> (t/Seqable String)])
(defn get-second-works [in]
(map (t/fn [i :- Pair] (second i)) in))
In a nutshell, passing the second function directly to map doesn't work - I
have to wrap it in the core.typed function macro.
What's up with that?
Cheers.
(error is:
Type Error (rest_api/types.clj:459:3) Polymorphic function map could not be
applied to arguments:
Polymorphic Variables:
c
a
b
Domains:
[a b ... b -> c] (t/NonEmptySeqable a) (t/NonEmptySeqable b) ... b
[a b ... b -> c] (t/U (Seqable a) nil) (t/U (Seqable b) nil) ... b
Arguments:
(t/All [x] (t/IFn [(t/HSequential [t/Any x t/Any *]) -> x :object {:id 0,
:path [(Nth 1)]}] [(t/Option (t/I (t/CountRange 0 1) (Seqable x))) -> nil]
[(t/I (t/CountRange 2) (Seqable x)) -> x] [(t/Option (Seqable x)) ->
(t/Option x)])) (IPersistentVector Pair)
Ranges:
(t/NonEmptyASeq c)
(t/ASeq c)
with expected type:
(t/Seqable String)
in: (map second in)