I meant when I change:

(t/HVec [Keyword (t/U Keyword (t/HVec [Keyword Number])) t/Any t/Any *])  
to  (t/HVec [Keyword (t/I Keyword (t/HVec [Keyword Number])) t/Any t/Any *])
                                
^^                                                                              
           
to                                  ^^
Still I think that making an intersection of it is wrong conceptually.


Thanks,
Sven

Am Donnerstag, 16. April 2015 23:08:30 UTC+2 schrieb Ambrose 
Bonnaire-Sergeant:
>
> I don't see an intersection, what do you mean?
>
> Thanks,
> Ambrose
>
> On Thu, Apr 16, 2015 at 4:43 PM, Sven Richter <sve...@googlemail.com 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I tried both destructuring and the nth form instead of second and first. 
>> None of which worked.
>>
>> However, if I change the Union to Intersection in 
>>
>> (t/HVec [Keyword (t/U Keyword (t/HVec [Keyword Number])) t/Any t/Any *])
>>
>> it works for the definition of the multimethod. Does that make sense? I 
>> thought Union was either one type or the other.
>>
>> Thanks,
>> Sven
>>
>>
>> Am Donnerstag, 16. April 2015 21:44:25 UTC+2 schrieb Ambrose 
>> Bonnaire-Sergeant:
>>>
>>> I don't think second's type is is smart enough.
>>>
>>> Try using nth or destructuring instead:
>>>
>>> (let [[f s] v]
>>>   (if (vector? s) (first s) s))
>>>
>>> or
>>>
>>> (if (vector? (nth v 1)) (first (nth v 1)) s)
>>>
>>> Thanks,
>>> Ambrose
>>>
>>> On Thu, Apr 16, 2015 at 3:39 PM, Sven Richter <sve...@googlemail.com> 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have this code:
>>>>
>>>> (defalias html-label (t/HVec [Keyword (t/HMap :mandatory {:for String}) 
>>>> String]))
>>>> (defalias html-form (t/HVec [Keyword (t/HMap :mandatory {:id String}) t
>>>> /Any *]))
>>>> (defalias html-form-group (t/HVec [html-label html-form]))
>>>>  
>>>> (t/ann dt->hiccup [(HVec [Keyword (U Keyword (HVec [Keyword Number])) t
>>>> /Any t/Any *]) -> 
>>>>                                html-form-group])
>>>> (defmulti dt->hiccup (t/fn [col :- pt/et-column]
>>>>                        (if (vector? (second col))
>>>>                          (first (second col))
>>>>                          (second col))))
>>>>
>>>> And here comes the error message when checking this function:
>>>>
>>>> Type Error (leiningen/td_to_hiccup.clj:25:34) Polymorphic function 
>>>> first could not be applied to arguments:
>>>> Polymorphic Variables:
>>>>         x
>>>>  
>>>> Domains:
>>>>         (t/HSequential [x t/Any *])
>>>>         (t/Option (t/EmptySeqable x))
>>>>         (t/NonEmptySeqable x)
>>>>         (t/Option (clojure.lang.Seqable x))
>>>>  
>>>> Arguments:
>>>>         (t/U Keyword (t/HVec [clojure.lang.Keyword java.lang.Number]))
>>>>  
>>>> Ranges:
>>>>         x :object {:path [(Nth 0)], :id 0}
>>>>         nil
>>>>         x
>>>>         (t/Option x)
>>>>  
>>>> in: (first (second col))
>>>> in: (first (second col))
>>>>  
>>>>  
>>>> ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.
>>>> clj:4403)
>>>>
>>>> My assumption is that the check (if (vector? (second col will return 
>>>> only true if it is this type: (HVec [Keyword Number]). However, I have 
>>>> the impression that core.typed does not resolve the if expression properly.
>>>> Or maybe I am missing something completely.
>>>>
>>>> Any hints or recommendations?
>>>>
>>>> Thanks,
>>>> Sven
>>>>
>>>>
>>>>  -- 
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@googlegroups.com
>>>> Note that posts from new members are moderated - please be patient with 
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+u...@googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to clojure+u...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to