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

depth for generics is broken #47

Closed
kuribas opened this issue Jun 30, 2020 · 5 comments
Closed

depth for generics is broken #47

kuribas opened this issue Jun 30, 2020 · 5 comments

Comments

@kuribas
Copy link

kuribas commented Jun 30, 2020

when using Generics, and incorrect depth is used:

> data Test = Test1 Int | Test2 String | Test3 String deriving (Generic, Show)
> instance Monad m => Serial m Test
> list 1 series :: [Test]
[Test1 0]
> list 2 series :: [Test]
[Test1 0,Test2 "",Test1 1,Test3 "",Test1 (-1)]

it looks like it's using the depth of the Rep Test, instead of the depth of Test.

@Bodigrim
Copy link
Owner

Could you please clarify what exactly is broken here?

@kuribas
Copy link
Author

kuribas commented Jun 30, 2020

well, I would expect the different constructors to appear equally in the generated list, but that doesn't seem the case. For example Test1 1 comes before Test3 "".

@Bodigrim
Copy link
Owner

I don't think this has anything to do with Generic. This is just a consequence of instances for Int and String:

> listSeries 0 :: [Int]
[0]
> listSeries 0 :: [String]
[]
> listSeries 1 :: [Int]
[0,1,-1]
> listSeries 1 :: [String]
[""]

@kuribas
Copy link
Author

kuribas commented Jul 1, 2020

Ah, indeed. Why do the instances for Int and String behave differently (one is empty at 0 level, the other not)?

@Bodigrim
Copy link
Owner

Bodigrim commented Jul 1, 2020

Because Int is considered to be a primitive type, but String is [Char], so you need to spend at least one unit of depth to get [].

@kuribas kuribas closed this as completed Jul 2, 2020
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

No branches or pull requests

2 participants