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 105605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:27:56+00:00 2026-05-11T01:27:56+00:00

Has anyone an idea how the type inference problem E > hd (cons 1

  • 0

Has anyone an idea how the type inference problem

E > hd (cons 1 nil) : α0 

with the typing environment

                E={                    hd : list(α1 ) → α1 ,                    cons : α2 → list(α2 ) → list(α2 ),                    nil : list(α3 ),                    1 : int                 } 

can be transferred in an unification problem?

Any help would really be appreciated!

  • 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. 2026-05-11T01:27:57+00:00Added an answer on May 11, 2026 at 1:27 am

    First, rename type variables so that none of the variables in your expression collide with variables in the typing environment. (In your example, this is already done since the expression references { a0 }, and the typing environment references { a1, a2, a3 }.

    Second, using new type variables, make a type variable for every subexpression within your expression, producing something like:

    nil : a4 1 : a5 cons : a6 (cons 1 nil) : a7 hd : a8 hd (cons 1 nil) : a0 // already had a type variable 

    Third, generate a set of equations among type variables which must hold. You can do this from the bottom up, from the top down, or in other ways. See Heeren, Bastiaan. Top Quality Type Error Messages. 2005. for extensive details on why you might want to choose one way or another. This will result in something like:

    a4 = list(a3) // = E(nil) a5 = int // = E(1) a6 = a2 -> list(a2) -> list(a2) // = E(cons)  // now it gets tricky, since we need to deal with application for the first time a5 = a2 // first actual param of cons matches first formal param of cons a4 = list(a2) // second actual param of cons matches type of second formal param of cons a7 = list(a2) // result of (cons 1 nil) matches result type of cons with 2 params  a8 = list(a1) -> a1 // = E(hd)      // now the application of hd a7 = list(a1) // first actual param of hd matches type of first formal param of hd a0 = a1 // result of hd (cons 1 nil) matches result type of hd with 1 param 

    Note carefully that if the same function was used from the type environment twice, we would need more new type variables (in the second step, above) to unify with, so that we wouldn’t accidentally make all calls to cons use the same type. I’m not sure how to explain this part more clearly, sorry. Here we are in the easy case since hd and cons are each only used once.

    Fourth, unify these equations, resulting in (if I haven’t made a mistake) something like:

    a4 = list(int) a5 = int a6 = int -> list(int) -> list(int) a7 = list(int) a8 = list(int) -> int a0 = int 

    Rejoice, you now know the type of every subexpression in your original expression.

    (Fair warning, I’m somewhat of an amateur myself in these matters, and I may well have made a typographical error or inadvertently cheated somewhere here.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer First, I think that the instance-based approach is correct. Using… May 11, 2026 at 10:46 am
  • added an answer No, not reliably. The number of cycles that it takes… May 11, 2026 at 10:46 am
  • added an answer If you have binary data like this: string buffer =… May 11, 2026 at 10:46 am

Related Questions

Has anyone an idea how the type inference problem E > hd (cons 1
Has anyone written an 'UnFormat' routine for Delphi? What I'm imagining is the inverse
Has anyone come across an example of a non .Net consumer of an ADO.NET
Has anyone been able to get an NHibernate-based project up and running on a
Has anyone used CSLA in an application that has a WPF front end and
Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET
Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project?
Has anyone seen this error when trying to call an external C function from
Has anyone run into this error message before when using a timer on an
Has anyone got to some good code to zoom into an image using javascript?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.