Can I have a function in a data constructor? Like:
data Something = (a->b) Something1 Something2
Yeah, of course you can. The only important thing is that you (always) need a name for your data constructor:
data <name> <para0> <param1> ... = <constructor> <arg0> <arg1> <arg2> ...
So for our example, it becomes
data Something a b = Constructor (a -> b) Something1 Something2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With