plutus
plutus copied to clipboard
Use of ranges in Plutus
Area
[X] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code [] Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries [] Marlowe Related to Marlowe [] Other Any other topic (Playgrounds, etc.)
Describe the feature you'd like
I'd like be able to use Ranges in lists within Plutus. Like [0..10] instead i have to write [0,1,2,3,4,5,6,7,8,9,10] otherwise it wont compile
It is possible to use enumFromTo.
Indeed you can use enumFromTo. Unfortunately GHC elaborates ranges to enumFromTo from base and we use a different one, so we'd either have to insist on everybody enabling RebindableSyntax by default, which is very pervasive, or to replace enumFromTo from base with our own behind the user's back and hardcode that into the compiler -- and neither of those is a good option. So for now, the only workaround is to use enumFromTo manually, but we'll keep this issue in mind to hopefully address it somehow in future.