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

Adds Matching and TermRewriting to Data.Comp.Multi #17

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

Conversation

tomberek
Copy link
Contributor

Uses unsafeCoerce to get around phantom parameter issues. I welcome any suggestions to remove this wart.

@tomberek
Copy link
Contributor Author

@pa-ba I seem to be stuck with adding TermRewriting. Is it possible to allow GADT and type safe rewriting?

@emilaxelsson
Copy link
Contributor

One way to avoid unsafeCoerce is to use something like

data ET f where
    ET :: Typeable a => f a -> ET f

instead of E. Then you should be able to replace unsafeCoerce with Data.Typeable.gcast.

One downside is that you'll have to be able to extract a Typeable constraint for any node in a Term in order to convert to/from ET. One way to do this is to use :&: to pair each node with a witness. Another way is to require the h-functor to be a member of a class like this one:

class TypeableIndex h where
    witTypeableIndex :: h f a -> Dict (Typeable a)

Dict is defined in the constraints package. So whenever you need a Typeable constraint for a node n, you can just do:

    case witTypeableIndex n of
        Dict -> ...

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