Skip to content

Repair Agda's REPL (agda -I) to work with --safe flag #4649

Closed

Description

@txa

Especially for teaching it would be nice if agda had a top-level REPL (read-eval-print loop) so that one can evaluate expressions interactively without always having to go via C-c C-n. Also I would like to print streams using costrings.

Has this been discussed before? What would be the effort and possible issues?

Activity

  1. nad commented on May 13, 2020

    @nad
    Collaborator

    Agda already has a REPL, but it is unmaintained. Try agda -I. Currently it does not work very well with code that uses --safe, but I guess that could be fixed.

    Also I would like to print streams using costrings.

    I'm not sure exactly what you mean. Can't you use the following function from the standard library?

    putStr∞ : Costring → IO ⊤
  2. added
    type: enhancement
    on May 13, 2020
  3. pnlph commented on May 13, 2020

    @pnlph
    Contributor

    To add some information, there is a recent comparison among several programming languages with REPLs and typed holes put up together by @ice1000

  4. added
    REPL
    on May 13, 2020
  5. txa commented on May 13, 2020

    @txa
    Author

    Ok, first of all as you already indicated there seem to be some issues with agda -I. Just trying to load Data.Nat doesn't seem to work:

    txa@sean agda-src % agda -I test.agda  
     
    The interactive mode is no longer under active development. Use at your own risk.
    Checking test (/Users/txa/agda-src/test.agda).
     Checking Data.Nat (/Users/txa/agda/std-lib/src/Data/Nat.agda).
      Checking Data.Nat.Base (/Users/txa/agda/std-lib/src/Data/Nat/Base.agda).
       Checking Level (/Users/txa/agda/std-lib/src/Level.agda).
    /Users/txa/agda/std-lib/src/Data/Nat/Base.agda:14,1-29
    Cannot set OPTIONS pragma --allow-unsolved-metas with safe flag.
    when scope checking the declaration
      open import Level using (0ℓ)
    
    

    Also I would like to be able to open a REPL in a separate buffer after loading the current buffer via an emacs command.

  6. nad commented on May 13, 2020

    @nad
    Collaborator

    If you want to play around with the REPL right now you can comment out two lines:

    prag <- allowUnsolvedFlag (optPragmaOptions o)

    , optPragmaOptions = prag

    However, I guess that this may break some part of the REPL.

  7. changed the title [-]REPL for agda (feature request)[/-] [+]Repair Agda's REPL (agda -I) to work with --safe flag[/+] on May 15, 2020
  8. added
    safe
    on May 15, 2020
  9. added this to the 2.6.2 milestone on May 15, 2020
  10. self-assigned this
    on May 16, 2020
  11. andreasabel commented on May 16, 2020

    @andreasabel
    Member

    Fixing this by allowing --safe and --allow-unsolved-metas to coexist in -I mode.

  12. added a commit that references this issue on May 21, 2020
    c8366c1
  13. nad commented on May 26, 2020

    @nad
    Collaborator

    Now --allow-unsolved-metas is turned on also in imported modules. Test case:

    {-# OPTIONS --safe #-}
    
    module B where
    
    bad : {A : Set} → A
    bad = ?
    {-# OPTIONS --safe #-}
    
    module A where
    
    import B

    Is this intended?

  14. 4 remaining items

  15. nad commented on May 27, 2020

    @nad
    Collaborator

    I don't think Agda should accept code with holes when --safe is used. Perhaps it is fine to leave it as it is for now, because we do advertise that agda -I is not supported. However, there seems to be interest in actually supporting agda -I, so I don't think we should close this issue.

    Does anyone know why --allow-unsolved-metas is turned on? Apparently it has been like this since 2006 (ff2ccf6), but back then this setting was used also for the Emacs mode. I suggest that we turn off --allow-unsolved-metas. Perhaps something breaks, but I would assume that it breaks in a "safe" way: fewer programs are accepted, not more.

  16. andreasabel commented on May 27, 2020

    @andreasabel
    Member

    I wouldn't say that agda -I needs to speak with authority on what is safe and what not. It is a REPL to tinker around and evaluate stuff.

    Does anyone know why --allow-unsolved-metas is turned on?

    I suppose to enable to interactively give solutions to metas.

    However, there seems to be interest in actually supporting agda -I, so I don't think we should close this issue.

    Users can always open issues when they seek functionality or find bugs. The OP here was fixed, thus, I do not see a reason why to keep this issue in limbo.

  17. added
    safe
    and removed
    safe
    on May 27, 2020
  18. nad commented on May 27, 2020

    @nad
    Collaborator

    I don't think we should ignore issues related to --safe.

    If there are no objections I can revert your change and turn off --allow-unsolved-metas.

  19. ice1000 commented on May 28, 2020

    @ice1000
    Member

    I would ask why does the REPL forcibly requires --allow-unsolved-metas. We can work with --safe files with unsolved metas in Emacs, right?

  20. nad commented on May 28, 2020

    @nad
    Collaborator

    This code has been unmaintained for a long time. I guess that it was not updated when the Emacs mode was changed.

    One practical consequence of using --allow-unsolved-metas that has not been mentioned above is that in many cases Agda decides that the options have changed and decides to typecheck everything from scratch.

  21. added
    allow-unsolved-metas
    on Dec 15, 2020
  22. added a commit that references this issue on Feb 7, 2021
  23. self-assigned this
    on Feb 7, 2021
  24. andreasabel commented on Nov 9, 2024

    @andreasabel
    Member

    This issue has been closed as fixed but the OP persists:

    Cannot set OPTIONS pragma --allow-unsolved-metas with safe flag.

  25. andreasabel commented on Nov 9, 2024

    @andreasabel
    Member

    A never mind, I got confused by the error message (that seems to be ignored): agda -I does complain about --safe --unsolved-metas but still lets me work with open metas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

REPLallow-unsolved-metashelp wantedsafetype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions