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

improve tracing: check/log pattern matches on unknown/known data #20

Closed
jwaldmann opened this issue Jun 7, 2013 · 4 comments
Closed

Comments

@jwaldmann
Copy link
Collaborator

for debugging the space/time behaviour I want to know, for each case, how often it was happening on known data, and how often on unknown data. Of course "known" is better since it does not require encoding and merging.

  • logging: collect this information (while the abstract program is running) and print it in a suitable form
  • checking: I want to put some annotation in the source that says "this case should ONLY be executed on known data"

as long as we don't have the "modes" system, if such an annotation is present, CO4 does not generate code for matching unknown data and merging the results, but instead emits code that will throw an exception.

@jwaldmann
Copy link
Collaborator Author

simple proposal (a.k.a. Hack) for checking:

instead of case x of ... allow to write case known x of where

  • semantically known = id
  • but for compiling: only generate the code for the case that the constructor is statically known (will throw an exception if this is not the case, exception should contain line number or similar)

come to think of it - this known x could be put anywhere (not just under the case) and it will just check (at runtime) that the top constructor indeed is known.

@abau
Copy link
Owner

abau commented Jun 24, 2013

known x

148c8a6 provides assertKnown and assertDefined with the given semantics (the name known is already taken by the allocators). Both functions require import CO4.Prelude.

@jwaldmann
Copy link
Collaborator Author

commit 534ab80 contains very simple constraint that recurses on a known list (with unknown elements)

constraint s xs = eqNat8 s ( summe xs)

summe xs = case assertKnown xs of
    [] -> nat8 0
    x:xs' -> plusNat8 x (summe xs')

when running it with assertions enabled, I get an exception:

ghci CO4/Test/Assert.hs

*Main> main
Start producing CNF
*** Exception: EncodedAdt.Overlapping.constantConstructorIndex: no flags

where I was expecting that it works without exception.

@abau
Copy link
Owner

abau commented Jun 24, 2013

fixed by f823290

@abau abau closed this as completed Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants