core.typed

Several failure cases for comp for polyadic fns and type variables

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Description

comp doesn't work for several common uses

Literal sets can't be used, neither can the well-known identity function

> (cf (comp #{:a :b} identity)
      [Keyword -> (Option Keyword)])

    Type Error (/tmp/form-init7065637308785250377.clj:1:5) Polymorphic function comp could not be applied to arguments:
    Polymorphic Variables:
	    x
	    y
	    b
    Domains:
	    (typ/IFn [x -> y]) (typ/IFn [b ... b -> x])
    Arguments:
	    (typ/HSet #{:b :a}) (All [x] (typ/IFn [x -> x :filters {:then (! (U false nil) 0), :else (is (U false nil) 0)} :object {:id 0}]))
    Ranges:
	    (typ/IFn [b ... b -> y])
    with expected type:
	    (typ/IFn [Keyword -> (Option Keyword)])
    in: (comp #{:b :a} identity)

This seems to be a general problem with polyadic Fns

;; The return type of
> (cf (comp first first))
(typ/IFn [(U nil (I (typ/ExactCount 0) (clojure.lang.Seqable typ/Nothing))) -> nil])
;; seems to be somewhat lacking

;; using it on anything else than empty collections doesn't check
> (cf ((comp first first) []))
nil
> (cf ((comp first first) [[]]))

    Type Error (/tmp/form-init7065637308785250377.clj:1:5) Function (comp first first) could not be applied to arguments:
    Domains:
	    (U nil (I (typ/ExactCount 0) (clojure.lang.Seqable typ/Nothing)))
    Arguments:
	    (HVec [(HVec [])])
    Ranges:
	    nil
    in: ((comp first first) [[]])

;; even the very simple case of
> (cf (comp inc inc))
(typ/IFn [Long -> Long])
;; doesn't do justice 

;; to the magnificent type of
> (cf inc)
(typ/IFn [java.lang.Long -> java.lang.Long] [java.lang.Double -> java.lang.Double] [typ/AnyInteger -> typ/AnyInteger] [java.lang.Number -> java.lang.Number])

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: