Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: Backlog
    • Components: None
    • Labels:
      None

      Description

      Problem

      If two functions take similar keyword arguments, we have to write them out twice.

      (ann make-contract [& :optional {:name (U Symbol String)
                                       :first-order [Any :-> Any]
                                       :projection [Blame :-> [Any :-> Any]]
                                       :flat? Boolean}
                          :-> Contract])
      
      (ann make-flat-contract [& :optional {:name (U Symbol String)
                                            :first-order [Any :-> Any]
                                            :projection [Blame :-> [Any :-> Any]]
                                            :flat? Boolean}
                               :-> Contract])
      

      Since HMap syntax is very similar and keyword arguments often flow into HMap types, it would be great to just specify these as HMap types.

      (defalias KW 
        (HMap :optional {:name (U Symbol String)
                         :first-order [Any :-> Any]
                         :projection [Blame :-> [Any :-> Any]]
                         :flat? Boolean}))
      (ann make-contract [& :HMap KW :-> Contract])
      
      (ann make-flat-contract [& :HMap KW :-> Contract])
      

      Questions

      What does a union of HMap's mean?

      eg.

      (defalias KW 
        (U '{:a Int}
           '{:b Int}))
      (ann make-contract [& :HMap KW :-> Contract])
      

      What does nil mean?

      (defalias KW 
        (U '{:a Int}
           nil))
      (ann make-contract [& :HMap KW :-> Contract])
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ambrosebs Ambrose BS
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: