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

The Archive Base Latest Questions

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

I am working through Graham Hutton’s Programming in Haskell , and an exercise in

  • 0

I am working through Graham Hutton’s Programming in Haskell, and an exercise in Chapter 3 asks “What is the type?” for the function twice f x = f (f x).

I think I understand why the answer is twice :: (t -> t) -> t -> t. (Edit: I did not understand why. See my comment on Paolo’s answer.) However, to experiment I wrote another function thrice f x = f (f (f x)).

What I definitely don’t understand is why thrice also has a type of thrice :: (t -> t) -> t -> t.

They work the way I would expect (see below), but I can’t see how the type of thrice makes sense.

From ghci:

>> twice tail [0,1,2,3,4]
[2,3,4]
>> thrice tail [0,1,2,3,4]
[3,4]
  • 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-27T01:20:35+00:00Added an answer on May 27, 2026 at 1:20 am

    Sorry, maybe I don’t understand your question, but if you look at your own example with list, you’ll see that in both twice and thrice’s case, the inputs are a function from list to list (tail) and a list ([0,1,2,3,4]) and the return type is a list.

    So both twice and thrice match the signature (t -> t) -> t -> t: a function from t to t (in your case tail), a t (in your case a list) and another t (list) in return

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

Sidebar

Related Questions

I'm working my way through Graham Hutton's Haskell book, and in his recursion chapter,
Working through a sample in Chapter 3 of Programming in Scala, the following code
While working through Real World Haskell, I tried to complete the palindrome exercise using
I'm currently working through Thinking in C++, and chapter 9, exercise 15 gives instructions
I'm working my way through Graham's book On Lisp and can't understand the following
I've been working through Practical Common Lisp and as an exercise decided to write
I'm working through previous years ACM Programming Competition problems trying to get better at
I'm working through some homework and a question on a previous exam paper asks
I am working through some of the exercises in The C++ Programming Language by
I'm working through the tutorials in the Beginning iPhone Development book. I'm on chapter

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.