Playing around with generators and pattern matching in racket I run into the following error while practicing lazily destructuring a collection and I can't figure out what the error is nor why it happens.
(require racket/match)
(require racket/generator)
(require data/collection)
(sequence->list
(in-generator
(let recur ([seq '(1 2 3)])
(match seq
[(sequence) (void)]
[(sequence next next-rest ...)
(yield next)
(recur next-rest)]))))
Gives me the following error:
sequence->list: contract violation
expected: sequence?
given: #<sequence>
in: the 1st argument of
(-> sequence? (listof any/c))
contract from:
<pkgs>/collections-lib/data/collection/collection.rkt
blaming: /var/folders/g4/0st3r3c513n6ymf2nkw11ml40000gn/T/ob-racket-CFPotf
(assuming the contract is correct)
at: <pkgs>/collections-lib/data/collection/collection.rkt:64.3
context...:
/usr/local/Cellar/minimal-racket/7.7/share/racket/collects/racket/contract/private/blame.rkt:347:0: raise-blame-error
/usr/local/Cellar/minimal-racket/7.7/share/racket/collects/racket/contract/combinator.rkt:324:9
/usr/local/Cellar/minimal-racket/7.7/share/racket/collects/racket/contract/private/arrow-val-first.rkt:486:18
"/var/folders/g4/0st3r3c513n6ymf2nkw11ml40000gn/T/ob-racket-CFPotf": [running body]
temp35_0
for-loop
run-module-instance!
perform-require!
Without the generator and if I'm just doing (cons next (recur next-rest)) everything works fine so it shouldn't have anything to do with my pattern matching code. But then again, I'm pretty confident with generators and have done things like this plenty of times, just without the pattern matching bit. I am pretty sure that this should work but have no clue why I'd be getting this error nor even what it means.