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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:19:48+00:00 2026-05-11T01:19:48+00:00

When I have some function of type like f :: (Ord a) => a

  • 0

When I have some function of type like

f :: (Ord a) => a -> a -> Bool f a b = a > b 

I should like make function which wrap this function with not.

e.g. make function like this

g :: (Ord a) => a -> a -> Bool g a b = not $ f a b 

I can make combinator like

n f = (\a -> \b -> not $ f a b) 

But I don’t know how.

*Main> let n f = (\a -> \b -> not $ f a b) n :: (t -> t1 -> Bool) -> t -> t1 -> Bool Main> :t n f n f :: (Ord t) => t -> t -> Bool *Main> let g = n f g :: () -> () -> Bool 

What am I doing wrong?

And bonus question how I can do this for function with more and lest parameters e.g.

t -> Bool t -> t1 -> Bool t -> t1 -> t2 -> Bool t -> t1 -> t2 -> t3 -> Bool 
  • 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. 2026-05-11T01:19:48+00:00Added an answer on May 11, 2026 at 1:19 am

    Unless you want to go hacking around with typeclasses, which is better left for thought experiments and proof of concept, you just don’t generalize to multiple arguments. Don’t try.

    As for your main question, this is most elegantly solved with Conal Elliott’s semantic editor combinators. A semantic editor combinator is a function with a type like:

    (a -> b) -> F(a) -> F(b) 

    Where F(x) is some expression involving x. There are also ‘contravariant’ editor combinators which take a (b -> a) instead. Intuitively, an editor combinator selects a part of some larger value to operate on. The one you need is called result:

    result = (.) 

    Look at the type of the expression you’re trying to operate on:

    a -> a -> Bool 

    The result (codomain) of this type is a -> Bool, and the result of that type is Bool, and that’s what you’re trying to apply not to. So to apply not to the result of the result of a function f, you write:

    (result.result) not f 

    This beautifully generalizes. Here are a few more combinators:

    argument = flip (.)     -- contravariant  first f (a,b) = (f a, b) second f (a,b) = (a, f b)  left f (Left x) = Left (f x) left f (Right x) = Right x ... 

    So if you have a value x of type:

    Int -> Either (String -> (Int, Bool)) [Int] 

    And you want to apply not to the Bool, you just spell out the path to get there:

    (result.left.result.second) not x 

    Oh, and if you’ve gotten to Functors yet, you’ll notice that fmap is an editor combinator. In fact, the above can be spelled:

    (fmap.left.fmap.fmap) not x 

    But I think it’s clearer to use the expanded names.

    Enjoy.

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

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you're doing a POST query, you need to use… May 12, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Or should I not have both an exception method and… May 12, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Try this: ThisProcess.MainWindowTitle I was playing with GetWindowText from user32.dll… May 12, 2026 at 6:20 pm

Related Questions

I'm trying to fix something in some Objective C++ (?!) code. I don't know
I recently took a class at school where we had to learn Scheme to
I've been learning F#, and I'm writing a tool in it. Everything works fine
I am trying to figure out how to define a function that works on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.