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

Implement pragma for declaring nat optimizations #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fabianhjr
Copy link
Contributor

No description provided.

@fabianhjr fabianhjr marked this pull request as draft May 3, 2020 03:50
@fabianhjr fabianhjr force-pushed the generalize-nat-hack branch 2 times, most recently from 3948eaa to 2840e23 Compare May 3, 2020 04:31
@fabianhjr fabianhjr marked this pull request as ready for review May 3, 2020 04:37
@fabianhjr
Copy link
Contributor Author

Helped me improve the performance of an alternative idris2 prelude I am playing with, tested with mock of ProjectEuler problem #1:

module NaiveSolution

import Prelude

import Data.Integral
import Data.Nat.Integral

main : LinkedList Nat
main = filter (`divBy` (the Nat 3)) [(the Nat 1)..100]

@fabianhjr fabianhjr force-pushed the generalize-nat-hack branch 2 times, most recently from 2e4ecb6 to cd106f6 Compare May 3, 2020 07:02
@fabianhjr fabianhjr marked this pull request as draft May 3, 2020 07:05
@fabianhjr
Copy link
Contributor Author

Marceline discovered that this PR causes an explosion of memory usage while compiling Idris2 in Core/Binary (Extra ~ 5GB or so of memory usage)

@fabianhjr fabianhjr marked this pull request as ready for review May 3, 2020 07:33
@edwinb
Copy link
Owner

edwinb commented May 9, 2020

This does make the nat hack a bit less hacky, thanks! Is the compile time performance still an issue? Sometimes that can be due to ambiguity resolution going a bit out of control.

@fabianhjr
Copy link
Contributor Author

Yes, there is still an issue with Idris1 compilation of Idris2.

Idris2 runs fine though.


-- Prim Nat Optimizations

<|> do pragma "builtinNatZero"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we refactor this as something like:

do c <- builtinPragma
   n <- name
   atEnd indents
   pure (c n)

where builtinPragma is a big choice of parsers of the form
PrimNatSucc <$ pragma "builtinNatSucc"

Co-authored-by: MarcelineVQ <marcythevq@gmail.com>
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.

None yet

3 participants