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

It should be possible to have pragmas inside record definitions #2939

Closed lukaszcz closed 3 months ago

lukaszcz commented 3 months ago

The following

instance
functorMaybeI : Functor Maybe :=
  mkFunctor@{
    {-# specialize: [1] #-}
    map {A B} (f : A -> B) : Maybe A -> Maybe B
      | nothing := nothing
      | (just a) := just (f a)
  };

currently gives an error

   |
43 |     {-# specialize: [1] #-}
   |     ^
unexpected '{'
expecting <function definition>, <identifier>, or }

Instead, the pragma should be accepted and associated with the function map.

This is needed to be able to control the optimizations for instances.