Working Through Exercises in HtDP 2nd Edition

I like to keep the dependency on rack unit also in a submodule, like this:

#lang typed/racket

(module+ test
  (require typed/rackunit))

(struct time-since-midnight [{hours : Natural}] #:type-name TimeSinceMidnight)

(: since (TimeSinceMidnight -> Natural))
;; determine the number of minutes since midnight from `this` TimeSinceMidnight
(define (since tsm)
  (* 60 (time-since-midnight-hours tsm)))


(module+ test
  (check-equal? (since (time-since-midnight 1)) 60))

I also like to name the Type something different.

1 Like