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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:56:12+00:00 2026-05-31T13:56:12+00:00

I would like to create three Haskell functions: a , b , and c

  • 0

I would like to create three Haskell functions: a, b, and c.

Each function is to have one argument. The argument is one of the three functions.

I would like function a to have this behavior:

  • if the argument is function a then return function a.
  • if the argument is function b then return function b.
  • if the argument is function c then return function a.

Here’s a recap of the behavior I desire for function a:

a a = a
a b = c
a c = a 

And here’s the behavior I desire for the other two functions:

b a = a
b b = a
b c = c

c a = c
c b = b
c c = c

Once created, I would like to be able to compose the functions in various ways, for example:

  a (c b)
= a (b)
= c

How do I create these functions?

  • 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-31T13:56:14+00:00Added an answer on May 31, 2026 at 1:56 pm

    Since you have given no criteria for how you are going to observe the results, then a = b = c = id satisfies your criteria. But of course that is not what you want. But the idea is important: it doesn’t just matter what behavior you want your functions to have, but how you are going to observe that behavior.

    There is a most general model if you allow some freedom in the notation, and you get this by using an algebraic data type:

    data F = A | B | C
        deriving (Eq, Show) -- ability to compare for equality and print
    
    infixl 1 % 
    (%) :: F -> F -> F
    A % A = A
    A % B = C
    A % C = A
    B % A = A
    ...
    

    and so on. Instead of saying a b, you have to say A % B, but that is the only difference. You can compose them:

      A % (C % B)
    = A % B
    = B
    

    and you can turn them into functions by partially applying (%):

    a :: F -> F
    a = (A %)
    

    But you cannot compare this a, as ehird says. This model is equivalent to the one you specified, it just looks a little different.

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

Sidebar

Related Questions

I would like to create a function for a table that has three columns
I would like to create three Pull Down Menus..... This is how they would
Is there anyway I can create a not in clause like I would have
I would like create same as on stackoverflow - orange comunnicates, but i have
My problem is like this: In ASP DetailsView component we have three different EventArgs
I have a variable $Date that is automatically updated each day. I would like
I would like to create an iphone application that displays three rows of infinite
I would like to create from this image a styled DIV box for my
I would like to create a custom Button component with three labels: left-, center-,
I would like to create a column in a spreadsheet that accepts only three

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.