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

Use 'inspection-testing' to guarantee that implementation for TMap is as efficient as for TypeRepMap #33

Open
chshersh opened this issue Jul 9, 2018 · 8 comments

Comments

@chshersh
Copy link
Contributor

chshersh commented Jul 9, 2018

No description provided.

@chshersh chshersh added the tests label Jul 9, 2018
@vrom911 vrom911 added the Hacktoberfest https://hacktoberfest.digitalocean.com/ label Sep 30, 2018
@chshersh chshersh removed the Hacktoberfest https://hacktoberfest.digitalocean.com/ label Nov 7, 2018
@qoelet
Copy link

qoelet commented Feb 14, 2019

@chshersh @vrom911 is this still a valid/wanted task? If so I'll like to give it a go.

@chshersh
Copy link
Contributor Author

@qoelet Sure, go for it! But I would like you to add some documentation while you work on this. I never used inspection-testing by myself, so looking just at the code might be a little bit difficult to review.

@Cmdv
Copy link

Cmdv commented Sep 23, 2020

I've been taking a look at this issue, read the blog post to find out more about the library. But I'm not grasping what Tmap is as efficient as TypeRepMap?

Also been looking at the inspection-testing examples to try and find something that might fit the problem but with no luck.

I also saw the use in stan but that didn't give me clues either 😄

@chshersh
Copy link
Contributor Author

Hi @Cmdv! TypeRepMap is parametrized by a polymorphic type variable, and TMap is special case of TypeRepMap with Identify instead of the f type variable.

However, despite being a specialization of TypeRepMap, TMap implements almost all functions separately, e.g. insert.

inspection-testing is a Haskell library for checking, wether two functions are compiled to the same code in the end. And we want to check this for similar functions of TMap and TypeRepMap. I haven't used inspections-testing before, so this task requires some research 🙂

@Cmdv
Copy link

Cmdv commented Sep 24, 2020

@chshersh ah cool, so do I'd want to check for example:

insert :: forall a . Typeable a => a -> TMap -> TMap
insert x = coerce (F.insert @a @Identity $ coerce x)

insert :: forall a f . Typeable a => f a -> TypeRepMap f -> TypeRepMap f
insert x = fromTriples . addX . toTriples
where
tripleX :: (Fingerprint, Any, Any)
tripleX@(fpX, _, _) = (calcFp @a, toAny x, unsafeCoerce $ typeRep @a)
addX :: [(Fingerprint, Any, Any)] -> [(Fingerprint, Any, Any)]
addX l = tripleX : deleteByFst fpX l

making sure they compile to the same code?
do you test agains the empty function or is it against its results when being run?

@chshersh
Copy link
Contributor Author

@Cmdv Yes, you got the idea right 👍 Checking just functions without applying them to any arguments should be enough.

@Cmdv
Copy link

Cmdv commented Sep 24, 2020

Perfect I'll give it a go 😄

@Cmdv
Copy link

Cmdv commented Sep 25, 2020

After spending best part of the day trying to use haskell-language-server things seem to compile but they aren't working the the ./test dir for some reason.

I've tried both with cabal and stack but can't seem to get around it. 😢

Will try pick it up if I can get things working 😄

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

4 participants