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

[ fix ] some mistakes #64

Merged
merged 3 commits into from
Jun 17, 2024
Merged

[ fix ] some mistakes #64

merged 3 commits into from
Jun 17, 2024

Conversation

spcfox
Copy link
Contributor

@spcfox spcfox commented Jun 15, 2024

This should be an example of an implicit argument

### A Note of Caution: Lowercase Identifiers in Function Types
When writing down the types of proofs as we did above, one
has to be very careful not to fall into the following trap:
In general, Idris will treat lowercase identifiers in
function types as type parameters (erased implicit arguments).
For instance, here is a try at proofing the identity functor
law for `Maybe`:
```idris
mapMaybeId1 : (ma : Maybe a) -> map Prelude.id ma = ma
mapMaybeId1 Nothing = Refl
mapMaybeId1 (Just x) = ?mapMaybeId1_rhs
```

@spcfox
Copy link
Contributor Author

spcfox commented Jun 15, 2024

Did you mean «try it»?

(try id!), because Idris can't figure out on its own

result is still out of bounds:
modulo `2^bitsize` and subtracting `2^bitsize` if the result is still out of
range. For instance, for `Int8`, all operations calculate their results modulo
256, subtracting 256 if the result is still out of bounds:

```repl
Main> the Int8 2 * 127
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the old explanation:
2 * 127 = 254 % 256 - 128 = 126

The correct way to subtract 2^bitsize:
2 * 127 = 254 % 256 - 256 = -2

@spcfox spcfox changed the title [ fix ] replace Prelude.id with id in Eq [ fix ] some mistakes Jun 16, 2024
@spcfox

This comment was marked as off-topic.

@spcfox

This comment was marked as off-topic.

@stefan-hoeck
Copy link
Owner

Or it could be an implementation of the FromString:

implementation FromString Escaped where
  fromString s = MkEscaped (escape s) s Refl

I'll add this to my PR if you agree

Let's discuss this in its own PR. The two versions - your and mine - have distinct performance characteristics. In the current version of fromString, there will be no call to escape with strings where this is not required. On the other hand, fromString will not work with all string literals.

@stefan-hoeck
Copy link
Owner

Thanks a lot for these corrections.

@stefan-hoeck stefan-hoeck merged commit d2f914c into stefan-hoeck:main Jun 17, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants