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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:15:56+00:00 2026-06-02T18:15:56+00:00

I want to implement an order-insensitive version of functional application in Haskell. By way

  • 0

I want to implement an order-insensitive version of functional application in Haskell. By way of a little background: a prominent tradition in the semantics of natural language (deriving from Richard Montague, among others) assigns lambda functions of various types as the semantic values (sv’s) of expressions. The truth-value of a sentence is computed by performing functional application on the sv’s of the sentence’s constituents. For a simple example, consider:

tl = [1..10]

bill :: Int
bill = 1

tall :: Int -> Bool
tall = \x -> x `elem` tl

Think of the sentence ‘Bill is tall’ as a tree with the left leaf occupied by ‘Bill’ and the right leaf occupied by ‘tall’. We compute the truth-value of the sentence by applying the sv of the right leaf to the sv of the left leaf. Now consider ‘Some man is tall’: here the left leaf is occupied by `some man’ [the sv of which is of type :: (Int -> Bool) -> Bool] and the right leaf is occupied by ‘tall’ [the sv of which is of type :: (Int -> Bool)]. We compute the truth-value of the sentence by applying the sv of the left leaf to the sv of the right leaf.

So, in this system, given a tree with left leaf a and right leaf b, we first check which leaf is in the domain of the other, and then apply functional application accordingly: if a is in the domain of b, we do b(a), whereas if b is in the domain of a, we do a(b).

How would I implement this kind of “order-insensitive” functional application in Haskell? I have written some functions that determine which leaf is in the domain of the other by parsing the result of

show (typeOf a)

for a leaf a. However, this seems to me unnecessarily cumbersome. Ghci gives an error if you try to e.g. evaluate

bill tall

So a simple way to check which item is in the domain of the other would be to just try applying one item to the other, and seeing whether an error/exception results. My question, then, is: how do I catch exceptions which result from a type-mismatch? That is, how do I catch non-IO exceptions of this sort?

  • 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-02T18:15:58+00:00Added an answer on June 2, 2026 at 6:15 pm

    You can’t catch a type mismatch at run time; it’s a compile-time error. (At least, not without using ghc-api to compile code at runtime. ghci is a wrapper around ghc-api, which is why it can do this.) You would need to find a way to capture this type distinction in an ADT to do it at runtime, or possibly use a typeclass (this introduces other complications, though).

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

Sidebar

Related Questions

I want to implement a Facebook updates(user action and notifications) on my web application
I want to implement my own dynamic memory management system in order to add
I want to implement the following page by Asp.net version 4.0 and ajax but
I want to implement a custom identity model in order to connect to a
In my desktop-based WPF-application I want to implement a toolbar with key actions (add,
i want to implement a php script on my registration form in order to
I want to implement auto complete feature in a rails application. I am using
I'm trying to develop a physics simulation and I want to implement a fourth-order
I am working on a paint application for Android. Now I want to implement
I want implement in my software solution an VBA editor but in c# 3.0.

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.