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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:15:03+00:00 2026-05-31T07:15:03+00:00

Consider this combinator: S (S K) Apply it to the arguments X Y: S

  • 0

Consider this combinator:

S (S K)

Apply it to the arguments X Y:

S (S K) X Y

It contracts to:

X Y

I converted S (S K) to the corresponding Lambda terms and got this result:

(\x y -> x y)

I used the Haskell WinGHCi tool to get the type signature of (\x y -> x y) and it returned:

(t1 -> t) -> t1 -> t

That makes sense to me.

Next, I used WinGHCi to get the type signature of s (s k) and it returned:

((t -> t1) -> t) -> (t -> t1) -> t

That doesn’t make sense to me. Why are the type signatures different?

Note: I defined s, k, and i as:

s = (\f g x -> f x (g x))
k = (\a x -> a)
i = (\f -> f)
  • 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-31T07:15:05+00:00Added an answer on May 31, 2026 at 7:15 am

    Thanks to all who responded to my question. I have studied your responses. To be sure that I understand what I’ve learned I have written my own answer to my question. If my answer is not correct, please let me know.

    We start with the types of k and s:

       k  :: t1 -> t2 -> t1 
       k  =  (\a x -> a) 
    
       s  :: (t3 -> t4 -> t5) -> (t3 -> t4) -> t3 -> t5 
       s  =  (\f g x -> f x (g x)) 
    

    Let’s first work on determing the type signature of (s k).

    Recall s‘s definition:

    s = (\f g x -> f x (g x))
    

    Substituting k for f results in (\f g x -> f x (g x)) contracting to:

    (\g x -> k x (g x))
    

    Important The type of g and x must be consistent with k‘s type signature.

    Recall that k has this type signature:

       k :: t1 -> t2 -> t1
    

    So, for this function definition k x (g x) we can infer:

    • The type of x is the type of k‘s first argument, which is the type t1.

    • The type of k‘s second argument is t2, so the result of (g x) must be t2.

    • g has x as its argument which we’ve already determined has type t1. So the type signature of (g x) is (t1 -> t2).

    • The type of k‘s result is t1, so the result of (s k) is t1.

    So, the type signature of (\g x -> k x (g x)) is this:

       (t1 -> t2) -> t1 -> t1
    

    Next, k is defined to always return its first argument. So this:

    k x (g x)
    

    contracts to this:

    x
    

    And this:

    (\g x -> k x (g x))
    

    contracts to this:

    (\g x -> x)
    

    Okay, now we have figured out (s k):

       s k  :: (t1 -> t2) -> t1 -> t1 
       s k  =  (\g x -> x)
    

    Now let’s determine the type signature of s (s k).

    We proceed in the same manner.

    Recall s‘s definition:

    s = (\f g x -> f x (g x))
    

    Substituting (s k) for f results in (\f g x -> f x (g x)) contracting to:

    (\g x -> (s k) x (g x))
    

    Important The type of g and x must be consistent with (s k)‘s type signature.

    Recall that (s k) has this type signature:

       s k :: (t1 -> t2) -> t1 -> t1
    

    So, for this function definition (s k) x (g x) we can infer:

    • The type of x is the type of (s k)‘s first argument, which is the type (t1 -> t2).

    • The type of (s k)‘s second argument is t1, so the result of (g x) must be t1.

    • g has x as its argument, which we’ve already determined has type (t1 -> t2).
      So the type signature of (g x) is ((t1 -> t2) -> t1).

    • The type of (s k)‘s result is t1, so the result of s (s k) is t1.

    So, the type signature of (\g x -> (s k) x (g x)) is this:

       ((t1 -> t2) -> t1) -> (t1 -> t2) -> t1
    

    Earlier we determined that s k has this definition:

       (\g x -> x)
    

    That is, it is a function that takes two arguments and returns the second.

    Therefore, this:

       (s k) x (g x)
    

    Contracts to this:

       (g x)
    

    And this:

       (\g x -> (s k) x (g x))
    

    contracts to this:

       (\g x -> g x)
    

    Okay, now we have figured out s (s k).

       s (s k)  :: ((t1 -> t2) -> t1) -> (t1 -> t2) -> t1 
       s (s k)  =  (\g x -> g x)
    

    Lastly, compare the type signature of s (s k) with the type signature of this function:

       p = (\g x -> g x)
    

    The type of p is:

       p :: (t1 -> t) -> t1 -> t
    

    p and s (s k) have the same definition (\g x -> g x) so why do they have different type signatures?

    The reason that s (s k) has a different type signature than p is that there are no constraints on p. We saw that the s in (s k) is constrained to be consistent with the type signature of k, and the first s in s (s k) is constrained to be consistent with the type signature of (s k). So, the type signature of s (s k) is constrained due to its argument. Even though p and s (s k) have the same definition the constraints on g and x differ.

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

Sidebar

Related Questions

Consider this problem: I have a program which should fetch (let's say) 100 records
Consider this code... using System.Threading; //... Timer someWork = new Timer( delegate(object state) {
Consider this case: dll = LoadDLL() dll->do() ... void do() { char *a =
Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable
Consider this: public class TestClass { private String a; private String b; public TestClass()
consider this code block public void ManageInstalledComponentsUpdate() { IUpdateView view = new UpdaterForm(); BackgroundWorker
Consider this example table (assuming SQL Server 2005): create table product_bill_of_materials ( parent_product_id int
Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); }
Consider this trigger: ALTER TRIGGER myTrigger ON someTable AFTER INSERT AS BEGIN DELETE FROM
Consider this example (typical in OOP books): I have an Animal class, where each

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.