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

Investigate generation of functions which have outputs that depend on their inputs #3

Open
LightAndLight opened this issue Aug 13, 2018 · 6 comments

Comments

@LightAndLight
Copy link
Collaborator

There were a couple of questions in the reddit thread about this kind of idea.

I think it's cool but I don't know if it's possible. The main example of monotonicity requires knowledge of the entire domain and codomain, which isn't captured by a -> Gen b anyway. At the very least we need to be aware of the history of inputs to the function.

The memo-trie approach works by lazily enumerating all the possible inputs to the function, so if we wanted to generate a monotonic function then somehow each input would have to have a knot that knows about all the other inputs. I don't know that it works.

@tscholak
Copy link

lol, I just ran into this problem. any idea how this may be accomplished?

@LightAndLight
Copy link
Collaborator Author

The monotonic example, or something else? I haven't thought about it for a while. What are you trying to do?

@tscholak
Copy link

I wanted to generate a function isomorphic to a -> Either a b.

@tscholak
Copy link

tscholak commented Jun 17, 2019

In the meantime, I circumvented the issue by generating Either () (Fn a b) and mapping this to a -> Either a b down the line. In the Left case, it's just the identity.

@LightAndLight
Copy link
Collaborator Author

Do you mean you generated an a -> Either a b for some specific a and b (say, Int and Bool)? Or you want to generate a parametric version (forall a b. a -> Either a b - there's only one function of this type- Left)?

@tscholak
Copy link

tscholak commented Jun 18, 2019

no, no, you are right, it would be for some unknown, but specific a and b.

implementing the following is not possible with what Hedgehog.Function provides today:

mkGen
  :: forall a b
   . (Hedgehog.Function.Arg a, Hedgehog.Function.Vary a)
  => Hedgehog.Gen b
  -> Hedgehog.Gen (Hedgehog.Function.Fn a (Either a b))

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