anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
457 stars 53 forks source link

Improve the inlining optimization to handle derived instances well #3186

Open lukaszcz opened 14 hours ago

lukaszcz commented 14 hours ago

Currently, derived instances which are recursive are inefficient, because the recursive call is done via the generic Eq.eq instead of calling the function being defined directly. Thus a recursive call is compiled to a case on the instance of Eq to fetch the function to be called. This instance should be inlined and the case eliminated. It currently isn't unless the pragma inline: case is present. This situation should be detected automatically.