Skip to content

[Improvement] Captured function type signature tvar's match declare block #1723

@Jason94

Description

@Jason94

Currently, the type environment restarts "numbering" tvars in type signatures from :a on. This can make docstrings in both Sly and generated documentation less clear.

Consider the standard library reference documentation for MonadState :: get:

GET :: (:A :B)

That's much less clear than the way the type signature is expressed in the declare in the code:

(get (:m :s))

For longer functions it gets even worse. Compare this function in the generated docstring:

UNMASK-THREAD-FINALLY :: ∀ A B C D E. (UNLIFTIO D A) (LIFTTO D E) (MONADIOTHREAD B C D) ⇒ (C → (UNMASKFINALLYMODE → (D UNIT)) → (E UNIT))

to the declare (maybe not immediately obvious, but trust me it's better):

  (declare unmask-thread-finally ((UnliftIo :r :io) (LiftTo :r :m) (MonadIoThread :rt :t :r)
                                  => :t -> (UnmaskFinallyMode -> :r Unit) -> :m Unit))

I think the worst part about this is that, in a library, you build up a consistent pattern of naming the tvars so that it kind of makes sense. In the above, :r is used for an UnLiftIo target consistently, :rt is used for a Runtime, :t is used for thread, etc. But across a whole library, those patterns get lost and what is :io in every declare block throughout the codebase could be :A in one function and :R in another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions