Questions tagged [typed-racket]

Typed Racket is a statically typed dialect of the Racket Scheme-derived language, that eases the migration from untyped to typed code.

Typed Racket is a statically typed dialect of that eases the migration from untyped to typed code.

Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type system that ensures the absence of many common errors. The Typed Racket Guide is intended for programmers familiar with Racket. For an introduction to Racket, see The Racket Guide.

130 questions
4
votes
2 answers

Can not apply prop:procedure in typed racket

When defining a struct in typed racket I can no longer use the prop:procedure. In normal racket I can do something like: (struct profile-unit (a t c g) #:property prop:procedure (thunk* 12)) (define t (profile-unit .1 .1 .2 .6)) (t) > 12 But…
mathk
  • 7,353
  • 6
  • 41
  • 70
4
votes
2 answers

Extract a type from a Typed Racket union

I have a function which, sort of like assoc, searches a symbol in list and returns either #f or the position in the list. The return type for this function should be a union of #f and Natural, (U #f Natural). But when I want to use the value as a…
tsgzj
  • 55
  • 4
4
votes
2 answers

How do I use with-type to use Typed Racket fragments within untyped modules?

The Typed Racket reference indicates that it's possible to use with-type to created “typed regions” within untyped code. The with-type form allows for localized Typed Racket regions in otherwise untyped code. It’s a little unclear how to actually…
Alexis King
  • 40,717
  • 14
  • 119
  • 194
4
votes
1 answer

Splicing syntax parameterize disables Typed Racket type annotations

When I run the following, I get a type error as expected: #lang typed/racket (require racket/stxparam) (define-syntax-parameter x #f) (syntax-parameterize ([x #'foo]) (: n Number) (define n "string") 'foo) But when I use…
Jack
  • 2,083
  • 11
  • 23
4
votes
2 answers

How to use `typed/racket` in `scribble/lp`

Is it possible to use other #langs in #lang scribble/lp for literate programming? For example, I want to use #lang typed/racket in #lang scribble/lp. How to realize that?
Ben
  • 2,892
  • 3
  • 15
  • 24
4
votes
1 answer

Understanding and using Typed Racket ellipsis properly

I want to define a function like this: (define (((lift fn) . gs) . args) (apply fn (map (lambda (g) (apply g args)) gs))) This basically "lifts" a function fn so that instead of accepting its normal arguments, it accepts functions and produces a…
Ord
  • 5,113
  • 4
  • 25
  • 42
4
votes
1 answer

How do you initialize a struct with default values in typed/racket?

I'm writing my first typed/racket application which is a cli application which asks you some statistical questions about your day such as how many hours you have slept the previous night, how much you have eaten, how many cups of coffee you had etc.…
rzetterberg
  • 9,544
  • 3
  • 40
  • 54
3
votes
0 answers

Typed racket GUI: pasteboard method set-area-selectable not working

I using the typed/racket/gui package to build an application. I need to turn off the selection box of the pasteboard% that is activated by default. Usually you would do this using the method set-area-selectable but somehow it is not working for me…
Nate0804
  • 67
  • 4
3
votes
1 answer

Determine the specific type of an argument in Racket when the argument's type is a union type

Apologies for the messy title—my technical vocab is lacking, and I was unsure of how to phrase this. How can I identify an argument in Racket as being of a certain type, without knowing either the constructors of the type (for use with match) a…
Michael
  • 113
  • 7
3
votes
1 answer

Is there any way to declare a type representing all the callable procedures(any procedure which is callable) in Typed Racket?

I'm working on SICP's metacircular-evaluator with Typed Racket and stuck when preparing primitive procedures beforehand with a list of cons of symbol and the procedure object. In the book the authors prepare primitive-procedures as below, however,…
lisperatsa
  • 33
  • 3
3
votes
0 answers

typed/racket: Declare struct in unit signature

Given I have Racket typed module (require typed/racket/unit Engine/engine2-sig) (define-unit engine2@ (import) (export engine2-sig^) (define-struct posn ([x : Natural] [y : Natural] [z : Natural]) #:transparent) ) (provide…
Bohdan Ivanov
  • 689
  • 8
  • 22
3
votes
1 answer

How can I use define/contract (or something equivalent) in Typed Racket?

I am writing a function that accepts only positive numbers, and I want to ensure that it is used correctly both inside the module and elsewhere. I wanted to write #lang typed/racket (require racket/contract) (: excited-logarithm (-> Number…
shadowtalker
  • 8,614
  • 2
  • 34
  • 70
3
votes
1 answer

Currying in Typed Racket

In regular Racket, ((curry * 2) 3) works as expected, with 6 as a result. However, in Typed Racket: > ((curry * 2) 3) ; readline-input:3:0: Type Checker: could not apply function; ; wrong number of arguments provided ; expected: 0 ; given: 1 ; …
Ealhad
  • 1,234
  • 15
  • 24
3
votes
0 answers

Using for*/first correctly with annotations in Typed Racket

I'm trying to understand how to use a for*/first loop in Typed Racket. Because everytime I try to execute my code I get a exception, that I need to add more annotations. I have the following for*/first loop: (for*/first ([current-pos : Integer…
3
votes
5 answers

Sum of a List with all Intermediate Values

I am trying to compute the sum of a list with all the intermediate values along the way. My code is as follows but it does not work. (: sums : (Listof Integer) -> (Listof Integer)) ;; compute the sum of a list, ;; produce all the intermediate sums…
testomg
  • 45
  • 6
1
2
3
8 9