Skip to content

Export return from IO.Primitive #2124

Closed

Description

@andreasabel

Trying to check my development Type-preserving compilation via dependently typed syntax (SPLS March 2023) with the current standard library, I get a failure for a trivial reason:

The module IO.Primitive doesn't export the following:
  return
when scope checking the declaration
  open import IO.Primitive public using (return; _>>=_)

In this state, I see no easy way to make my development work with both std-lib 1.7.1/2 and 2.0.

An easy fix would be to restore return to this module with the alias return = pure which could maybe be coming with a deprecation warning.
(Though in my view there is no consensus in the FP community that return is a bad word and pure the good word. Esp. when the return statement is the last of my function, it makes perfectly sense to say return result rather than pure result).

Ref: https://github.com/agda/agda-stdlib/blame/master/src/IO/Primitive.agda

Activity

  1. gallais commented on Oct 6, 2023

    @gallais
    Member

    The issue is that return clashes with case_return_of_.

  2. added a commit that references this issue on Oct 6, 2023
    804bf6f
  3. andreasabel commented on Oct 6, 2023

    @andreasabel
    MemberAuthor

    @gallais Please have a look at #2125 which adds the backwards-compatibility with v1.7 that I need for an IO-monadic Agda development (the one mentioned in the OP).

  4. jamesmckinna commented on Oct 6, 2023

    @jamesmckinna
    Collaborator

    [UPDATED] Suggest instead:

    • add the alias pure = return to v1.7.2 IO.Primitive (and, if necessary, any hiding (pure) directives in client modules where this might be a problem)
    • adding 'stub' versions of Effect.Functor and Effect.Applicative (and Effect.Monad?) to v1.7.2 which provide the Raw* functionality, but otherwise publicly re-export from Category.*; how much of the Category.* tree do you actually require for your development?
    • import in a both-versions-compatible way (in your talk-related client module(s)) open import IO.Primitive public using (_>>=_) renaming (pure to return)

    Does that work?
    TL;DR: patch/retrofit v1.7.2 (and if necessary, a minor version bump) so that it is forwards compatible with v2.0, not the other way round.

  5. added this to the v2.0 milestone on Oct 6, 2023
  6. jamesmckinna commented on Oct 10, 2023

    @jamesmckinna
    Collaborator

    The discussion on #2129 seems to be asking for a v1.7.3 (or back-patching v1.7.2). Suggest we lift this out as a separate issue, and collect a number of issues which might be solved by such a thing (such as these two, but what else?), together with some discussion/agreement about what (minimal) patches might be necessary? But I do worry that this would be opening a door...

  7. MatthewDaggitt commented on Oct 11, 2023

    @MatthewDaggitt
    Collaborator

    Given how widely return is used, maybe it should be case_return_of_ whose name should be changed? Thought I don't have any particular suggestions. Just throwing it out there @gallais ?

  8. gallais commented on Oct 11, 2023

    @gallais
    Member

    Yeah of course but as you said, there are no alternative name proposals (#356).
    And on the other hand, should we pollute the namespace with an alias for pure just because
    Haskell does so? Should we add fmap as an alias for _<$>_ because people may reach for
    it out of habit?

  9. andreasabel commented on Oct 12, 2023

    @andreasabel
    MemberAuthor

    Yeah of course but as you said, there are no alternative name proposals (#356).

    case_yield_of_ would use a synonym of "return".
    In other PLs (except maybe Coq), neither return nor yield is used for the return type, but always for the return value.

    Also case_return:_of_ is thinkable with the : emphasizing a return type.

  10. JacquesCarette commented on Oct 13, 2023

    @JacquesCarette
    Collaborator

    On Zulip, @jamesmckinna suggested case_returning_of_. I happen to also like your 'thinkable' suggestion. (i.e. either returning or return: would feel like an improvement). I don't feel that yield is much of an improvement for the very reason you mention: it still feels value-level rather than type-level.

  11. Taneb commented on Oct 13, 2023

    @Taneb
    Member

    I also like case_returning_of, I feel it reads fluently

  12. jamesmckinna commented on Oct 16, 2023

    @jamesmckinna
    Collaborator

    I'm pinching myself a little here... is it really the case that the only use(s) of case... return... of... in the library are in Function.Base (and README.Case which itself only uses one instance!)? It seems as though all other uses are of the derived form case... of..., in which case the renaming/deprecation return $\mapsto$ returning could/would be immediate...?

  13. MatthewDaggitt commented on Oct 16, 2023

    @MatthewDaggitt
    Collaborator

    Yup, that was what I found as well.

  14. added a commit that references this issue on Oct 16, 2023
  15. jamesmckinna commented on Oct 16, 2023

    @jamesmckinna
    Collaborator

    Alright, I'll bite... #2157

  16. added a commit that references this issue on Oct 16, 2023
  17. MatthewDaggitt commented on Oct 16, 2023

    @MatthewDaggitt
    Collaborator

    Which means I guess that we can now allow return to make a return. I do think we'll get a lot of complaints if we don't keep it.

  18. jamesmckinna commented on Oct 17, 2023

    @jamesmckinna
    Collaborator

    I'll let others who want return pick up that particular slack. But I would argue to retain #356 ie. pure as well as the factorisation of Monad via Applicative...

  19. jamesmckinna commented on Oct 17, 2023

    @jamesmckinna
    Collaborator

    Now that #2157 has been merged in, there will need to be an eventual update to the section on pattern lambdas in the readthedocs to reflect this...

  20. MatthewDaggitt commented on Oct 18, 2023

    @MatthewDaggitt
    Collaborator

    Nice spot!

  21. added a commit that references this issue on Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions