-
Notifications
You must be signed in to change notification settings - Fork 123
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
‘apply’ and ‘Fn’ for different arities #110
Comments
Silly me, we actually do have an instance for functions Sub Dict :: (Function a, CoArbitrary a, CoArbitrary b, Arbitrary c) :- Arbitrary (Fun a (b -> c)) so we can generate them just fine ( I am not familiar with the internals of the library, this is my attempt at a -- Doesn't work as intended
instance {-# OVERLAPPING #-} (Show a, Show b, Show c, Function b) => Show (Fun a (b -> c)) where
show = \case
Fun (_, _, False) _ -> "<fun>"
-- ↓ incorrect
Fun (f, _, True) _ -> showFunction (Pair (fmap function f)) Nothing Any thoughts? |
@Icelandjack we can generate and show I'd like Doing trickery is 👎 Maybe it will work with e.g. http://hackage.haskell.org/package/HList-0.4.1.0/docs/Data-HList-HCurry.html#v:hCurry but that functionality could be in a separate package, or at least tried somewhere to prove being useful and unproblematic. |
Agreed, I'll make a PR with |
The following are used in containers
I see two directions we can go. We can supply those functions, along with:
now it can be written
Alternatively we could use some type class trickery to provide a single function and pattern that supersede
apply{,2,3}
andFn{,2,3}
. So that the user never has to think about how many arguments their function has.I have some doubts about the effects that will have on inference.
One last solution: somehow define an
Arbitrary (Fun a (b -> c))
instance. I have not thought this through but if this makes sense it might be the most elegant solution.The text was updated successfully, but these errors were encountered: