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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:07:51+00:00 2026-06-05T12:07:51+00:00

Is there anyway to define a function like the following in Haskell? or True

  • 0

Is there anyway to define a function like the following in Haskell?

or True      True      = True
or True      undefined = True
or True      False     = True
or undefined True      = True
or undefined False     = undefined
or undefined undefined = undefined
or False     True      = True
or False     undefined = undefined
or False     False     = False

I don’t currently have a use case for it (though I’d be interested in one), I’m just interested if it’s possible.

  • 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-06-05T12:07:52+00:00Added an answer on June 5, 2026 at 12:07 pm

    Depending on your evaluation order (the order in which you inspect values) you can write a lazy version:

    Prelude> True || undefined
    True
    Prelude> undefined || True
    *** Exception: Prelude.undefined
    
    Prelude> :t or
    or :: [Bool] -> Bool
    
    Prelude> or [True, undefined]
    True
    

    in fact, the default definition in Haskell will behave like this, since Haskell is a lazy language.

    However, there’s no way to “skip” an undefined value, without looking at the value first, which will evaluate it to a bottom, which causes your expression to be undefined.

    Remember that lazy values are presents with ghosts inside them:

    enter image description here

    If you look inside the box, a ghost might get you.

    If checking for bottoms is important (e.g. as part of a testsuite) you can treat them as exceptions, and intercept them. But you wouldn’t do that in a pure function.

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

Sidebar

Related Questions

I have some debugging code that looks like the following: #define STRINGIFY(x) #x #define
Hi All is there any way to locally define a variable in a function
I am just considering if there is anyway to make a comment-like split lines
I have a Domain Model for Countries and States that looks like the following(see
So i have this txt file called Students.txt, I want to define a function
I used code like #define BLOCK_SIZE 32 to determine block size for kernel function.
Is there any way to define event procedures for form controls such as the
Is there any way to define a variable that can be used in multiple
Is there any way of defining macros (like tex macros o latex defines) in
Is there anyway to NSPerformService(@Tweet, [NSPasteboard generalPasteboard]); with an image? I know that simply

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.