Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agda Nat exports Unit somehow #840

Open
thomas-lamiaux opened this issue Jun 9, 2022 · 5 comments
Open

Agda Nat exports Unit somehow #840

thomas-lamiaux opened this issue Jun 9, 2022 · 5 comments

Comments

@thomas-lamiaux
Copy link
Contributor

thomas-lamiaux commented Jun 9, 2022

I was working on a file and I couldn't get how I was using Unit without importing it.
Turned out it was exported by imported Nat. I couldn't figure out where it is imported publicly.
I was thinking that this is a bit weird and shouldn't be?

I don't know if there is a link but I have noticed that the Nat Builtin imports the Bool Bultin and I haven't found a reason for that either

{-# OPTIONS --without-K --safe --no-universe-polymorphism
            --no-sized-types --no-guardedness --no-subtyping #-}

module Agda.Builtin.Nat where

**open import Agda.Builtin.Bool**

data Nat : Set where
  zero : Nat
  suc  : (n : Nat) → Nat

{-# BUILTIN NATURAL Nat #-}
@thomas-lamiaux thomas-lamiaux changed the title Agda builtin Nat exported in agda bultin Bool Agda builtin Nat exported Unit somehow Jun 9, 2022
@thomas-lamiaux thomas-lamiaux changed the title Agda builtin Nat exported Unit somehow Agda Nat exports Unit somehow Jun 9, 2022
@mortberg
Copy link
Collaborator

mortberg commented Jun 9, 2022

I'm confused, what does Agda.Builtin.Nat exporting Bool have to do with Unit?

No matter what it seems weird that Agda.Builtin.Nat imports Agda.Builtin.Bool if it doesn't have to. Seems like an issue for agda (unless there already is an open such issue)

@thomas-lamiaux
Copy link
Contributor Author

thomas-lamiaux commented Jun 9, 2022

Yes indeed no link.

I find the Unit.
Nat exports Nat.Literals that in turn exports some things publicly.
Is that normal :

  • Base is not self contained
  • The export of unit is public ?

@MatthiasHu
Copy link
Contributor

the Nat Builtin imports the Bool Bultin and I haven't found a reason for that

It does use Bool (for example in _==_ : Nat → Nat → Bool), so this is fine.

@MatthiasHu
Copy link
Contributor

The reason why Nat re-exports Unit is that the constructor tt : Unit has to be available as an instance for the fromNat function whenever a literal like 0 is used. (I just deleted the public re-export and waited for errors to find this out.)

I agree that this can be a little bit unexpected. But do we want to fix it? Use a custom NatFromNatTrivialConstraint type instead of of the Unit?

@MatthiasHu
Copy link
Contributor

MatthiasHu commented Aug 24, 2023

And a general "pro tip": C-c C-w tells you why something (e.g. Unit) is in scope. (In emacs.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants