I'm trying to read data from a database in typed Racket and convert it to a list of structures. The code below is the untyped version that works perfectly. This is the smallest bit I can make that demonstrates the problem.
#lang racket
(require db)
(define dbc (sqlite3-connect #:database "dmdb.sqlite3" #:mode 'read/write))
(struct player (name size str dex con base-hp current-hp base-ac attack) #:mutable)
(define get-players
(lambda (c)
(for/list
([(n s str dex con bhp chp bac attack)
(in-query c "select * from players")])
(player n s str dex con bhp chp bac attack))))
The typed version of the procedure is as shown below:
#lang type/racket
(require typed/db)
(: get-players (-> Connection (Listof player)))
(define get-players
(lambda (c)
(for/list
([(n s str dex con bhp chp bac attack)
(in-query c "select * from players")])
(player n s str dex con bhp chp bac attack))))
When I try to compile it in typed Racket I receive some strange error messages:
Type Checker: Expression should produce 9 values, but produces 1 values of
types SQL-Datum in: (for/list (((n s str dex con bhp chp bac attack
(in-query c "select * from players"))) (player n s str dex con bhp chp bac
attack))
Again, the code works perfectly as long as it is not typed.
Connectiontype from? - Leif Andersen