plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Use of ranges in Plutus

Open SaIG opened this issue 4 years ago • 2 comments

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

SaIG avatar Jun 17 '21 18:06 SaIG

It is possible to use enumFromTo.

vladimirlogachev avatar Apr 06 '22 20:04 vladimirlogachev

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.

effectfully avatar Apr 06 '23 15:04 effectfully