Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:55:25+00:00 2026-06-13T10:55:25+00:00

What kind of type inference does Typed Racket do? I found the following snippet

  • 0

What kind of type inference does Typed Racket do? I found the following snippet on the Racket mailing list:

The Typed Racket type system contains a number of features that go
beyond what’s supported in Hindley/Milner style type systems, and so
we can’t use that inference system. Currently, Typed Racket uses
local type inference to infer many of the types in your program, but
we’d like to infer more of them — this is an ongoing area of
research.

The blurb above uses the term “local type inference”, and I’ve also heard “occurrence typing” used a lot, but I’m not exactly sure what these terms mean.

It seems to me that the type inference system that Typed Racket currently uses is unnecessarily weak. Here’s an example of what I mean. The following does not type check:

(struct: pt ([x : Real] [y : Real]))

(define (midpoint p1 p2)
  (pt (/ (+ (pt-x p1) (pt-x p2)) 2)
      (/ (+ (pt-y p1) (pt-y p2)) 2)))

You have to explicitly annotate midpoint with (: midpoint (pt pt -> pt)), otherwise you get the error: Type Checker: Expected pt, but got Any in: p1. Why can’t the type checker just conclude from this that the types of p1 and p2 must be pt? Is this a fundamental limitation of the way that Racket implements types (i.e. is this line of reasoning actually wrong sometimes, because of some of Racket’s more advanced type features), or is this something that could possibly be implemented in the future?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:55:27+00:00Added an answer on June 13, 2026 at 10:55 am

    By default, unannotated top-level functions are assumed to have input and output types of Any. I offer this vague explanation: since Racket’s type system is so flexible, it can sometimes infer types that you wouldn’t expect, and allow some programs to typecheck when you might prefer them to emit a type error.

    Tangent: you can also use the define: form if that is what suits you.

    (define: (midpoint [p1 : pt] [p2 : pt]) : pt
      ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone please tell me how to extract this kind of data : [{number:8457215152,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0},{number:4363685555,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0}]
There are two kind of type declaration mentioned in dojo documentation. They are data-dojo-type
I am implementing a kind of IP finder for a particular type of network
So I looked into this enum type, and it kind of seems like a
Kind of need help understanding what this code actually outputs. Does it out put
I want to make a map-kind of container that has the following interface: public
I’ve been pondering about the C# and CIL type system today and I’ve started
I'm looking for a way to create some kind of value type hierarchical class
By ref table I'm referring to a kind of entity 'type' table, and by
I just heard of that there is a kind of type like this,a point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.