lexi-lambda / envy

An environment variable manager for Racket applications
https://lexi-lambda.github.io/envy/envy.html
17 stars 1 forks source link

Add custom coercion #5

Closed jackfirth closed 7 years ago

jackfirth commented 9 years ago

This PR adds support for a #:coerce keyword that allows a user to supply their own function for converting the environment variable string value into a value of the declared type. When provided, it overrides the default coercion for the declared type if there is one.

(: octal-string->integer (-> String Integer))
(define (octal-string->integer s)
  (cast (string->number s 8) Integer))

(define-environment-variable an-octal-integer : Integer #:coerce octal-string->integer)

Closes #4

jackfirth commented 7 years ago

Closing due to age