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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:22:32+00:00 2026-05-16T06:22:32+00:00

I’m working on an experimental programming language that has global polymorphic type inference. I

  • 0

I’m working on an experimental programming language that has global polymorphic type inference.

I recently got the algorithm working sufficiently well to correctly type the bits of sample code I’m throwing at it. I’m now looking for something more complex that will exercise the edge cases.

Can anyone point me at a source of really gnarly and horrible code fragments that I can use for this? I’m sure the functional programming world has plenty. I’m particularly looking for examples that do evil things with function recursion, as I need to check to make sure that function expansion terminates correctly, but anything’s good — I need to build a test suite. Any suggestions?

My language is largely imperative, but any ML-style code ought to be easy to convert.

  • 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-05-16T06:22:33+00:00Added an answer on May 16, 2026 at 6:22 am

    My general strategy is actually to approach it from the opposite direction — ensure that it rejects incorrect things!

    That said, here are some standard “confirmation” tests I usually use:

    The eager fix point combinator (unashamedly stolen from here):

    datatype 'a t = T of 'a t -> 'a
    
    val y = fn f => (fn (T x) => (f (fn a => x (T x) a)))
                   (T (fn (T x) => (f (fn a => x (T x) a))))
    

    Obvious mutual recursion:

    fun f x = g (f x)
    and g x = f (g x)
    

    Check out those deeply nested let expressions too:

    val a = let
       val b = let 
          val c = let
             val d = let
                val e = let
                   val f = let
                      val g = let
                         val h = fn x => x + 1
                      in h end
                   in g end
                in f end
             in e end
          in d end
       in c end
    in b end
    

    Deeply nested higher order functions!

    fun f g h i j k l m n = 
       fn x => fn y => fn z => x o g o h o i o j o k o l o m o n o x o y o z
    

    I don’t know if you have to have the value restriction in order to incorporate mutable references. If so, see what happens:

    fun map' f [] = []
      | map' f (h::t) = f h :: map' f t
    
    fun rev' [] = []
      | rev' (h::t) = rev' t @ [h]
    
    val x = map' rev'
    

    You might need to implement map and rev in the standard way 🙂

    Then with actual references lying around (stolen from here):

    val stack =
    let val stk = ref [] in
      {push = fn x => stk := x :: !stk,
       pop  = fn () => stk := tl (!stk),
       top  = fn () => hd (!stk)}
    end
    

    Hope these help in some way. Make sure to try to build a set of regression tests you can re-run in some automatic fashion to ensure that all of your type inference behaves correctly through all changes you make 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 484k
  • Answers 484k
  • 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
  • Editorial Team
    Editorial Team added an answer You should probably look at a framework that allows the… May 16, 2026 at 7:27 am
  • Editorial Team
    Editorial Team added an answer I would just query for the two special posts before… May 16, 2026 at 7:27 am
  • Editorial Team
    Editorial Team added an answer getlogin: This implements the C library function of the same… May 16, 2026 at 7:27 am

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.