nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
724 stars 121 forks source link

Can we rework Function to get more instances? #181

Open treeowl opened 7 years ago

treeowl commented 7 years ago

Currently,

class Function a where
  function :: (a -> b) -> (a :-> b)

Unfortunately, I don't see any way to write anything like

instance ... => Function (Fun a b)

Maybe I'm wrong, but that's how it appears. This is sad, because we can't generate arbitrary higher-order functions. I'm wondering if it's possible to rearrange things to make this possible. The first idea is that perhaps we should remove the codomain from consideration and really focus hard on the domain. What does a type have to look like to be a Function instance? Well, basically, it has to look like one of these:

  1. A type whose values can be listed
  2. An algebraic combination of Function instances
  3. A type that is isomorphic to an existing Function instance

I suspect it may be possible to express :-> with such a representation, but I'm not sure.

nick8325 commented 7 years ago

I think @koengit had worked on this a bit, and had managed to get second-order functions working but not higher-order ones. Koen, any comments?

treeowl commented 7 years ago

I'm now remembering having mentioned the vague notion to him a while back. I thought I remembered saying it somewhere, but I didn't find a ticket here so I thought I was mistaken.

On Jul 31, 2017 5:46 PM, "Nick Smallbone" notifications@github.com wrote:

I think @koengit https://github.com/koengit had worked on this a bit, and had managed to get second-order functions working but not higher-order ones. Koen, any comments?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nick8325/quickcheck/issues/181#issuecomment-319206069, or mute the thread https://github.com/notifications/unsubscribe-auth/ABzi_byYoQkd5JwSSiKDdDbYzEVbW9ZZks5sTktJgaJpZM4Ooy0W .