fjvallarino / monomer

An easy to use, cross platform, GUI library for writing Haskell applications.
BSD 3-Clause "New" or "Revised" License
575 stars 42 forks source link

Cannot Infer Types if Type Signatures Left Out #279

Closed liamzee closed 1 year ago

liamzee commented 1 year ago

I know that Haskell idiomatically uses type signatures to provide commenting, but Haskell cannot infer types on the UI builder etc if type signatures are left out.

Same applies to Widgets.

I think that for at least demonstrating monomer, it's useful to include the version without the type signatures because the type signature is liable to confuse newbies to Haskell.

Not sure if there's a practical workaround, though.

fjvallarino commented 1 year ago

@liamzee I'm not sure to which specific example you refer.

Sometimes leaving out the signature is clearer, but getting weird compilation errors can be even more confusing for new users. Given that Monomer relies quite a bit on lenses and that its compilation errors can be quite scary, having an explicit type signature reduces this type of problem.

liamzee commented 1 year ago

I've been trying to build a minimal monomer application, i.e, everything is left out, all you have is a window, for the minimal amount of code to get monomer to compile and open a window.

If you use void types for model and events, you'll need type signatures, and even if you populate the events, I think type inference will still fail without an explicit type signature.

Not really that big a deal; the workarounds are good enough, and I don't think monomer currently attracts anyone who might be interested in a completely simplified and unidiomatic type sig-less model.

liamzee commented 1 year ago

Closed. This is extremely niche, but in fact, it's possible to completely avoid data declarations entirely simply by reusing () as both a model and event type.

So the minimal app for demonstration only can actually be much, much shorter.