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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:05:30+00:00 2026-05-16T23:05:30+00:00

What does a very general function look like in functional programming? Somebody said we

  • 0

What does a very general function look like in functional programming?

Somebody said “we don’t have objects, but we have higher order functions”. Do higher order functions replace objects?

While programming object-oriented apps, I try to go from a more general to a more detailed idea, lots of times. If I try to do that in functional programming, am I going to need lots of higher order functions?

  • 1 1 Answer
  • 3 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-16T23:05:31+00:00Added an answer on May 16, 2026 at 11:05 pm

    This answer is oriented towards Haskell rather than Lisp because although lisp has higher order functions, idiomatic lisp can be and is often very object-oriented.

    We’ll also ignore inheritance (and ad-hoc polymorphism) which is commonly associated with object oriented programming, but is somewhat orthogonal.

    In general, abstract data types “replace” objects, in the sense that generally you use an object to bundle together a bunch of related data in e.g. Java or Python, and you declare a data type to do such a thing in Haskell or ML.

    However objects also bundle behavior with the data. So an object of a class has data, but also functions which can access and mutate that data. In a functional style, you’d simply declare the functions on your data type outside of that data type. Then encapsulation is provided by either modules or use of closures.

    On the latter point — closures and objects are duals, although it is not necessarily idiomatic to express them as such. There’s some very old-school discussion of this at the portland patterns wiki: http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent.

    Oh, and an example from oleg: http://okmij.org/ftp/Scheme/oop-in-fp.txt.

    Ignoring typeclasses (which are essential to idiomatic Haskell), and focusing just on core functional programming, here’s a sketch of a different approach to something that would be done with inheritance in an OO language. Function foo uses some object that implements interface A and some object that implements interface B to produce some Double. With higher order functions, you’d perhaps have a type signature of fooGen :: (a -> Double -> Double) -> (b -> String -> Double) -> a -> b -> Double.

    That signature says that fooGen takes a function from some a and a Double to another Double, and a function of some b and a String to a Double, and then it takes an a and a b, and finally it returns a Double.

    So now you can pass in the “interface” separately from the concrete values through partial application, by declaring, e.g., fooSpecialized = fooGen funcOnA funcOnB.

    With typeclasses, you can abstract away the concrete passing in of the “interface implementation” (or, in more proper language, dictionary), and declare foo :: HasSomeFunc a, HasSomeOtherFunc b => a -> b -> Double. You can think of the stuff on the left hand side of the => as declaring, loosely, the interfaces that your concrete a and b types are required to implement.

    This is all a handwavy and partial answer of course to an exceedingly general question.

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

Sidebar

Related Questions

Very simple question. What does the term 'seeding' mean in general? I'll put the
I have created a GUI for starting a Thread which does something very simple.
Very simple + silly question: Does clojure provide multi maps? I currently have something
Does anyone have examples/tutorials of exception handling in R? The official documentation is very
I have a slight dilema. This isn't general to backbone.js but it's certainly causing
Let's say I have a situation like so: $(window).load(function() { $(body).append(<div id='container'></div>); var i=1;
The linux file command does a very good job in recognising file types and
I am currently having trouble with a live wallpaper that does some very intensive
Does anyone know of some (very) simple tutorials on line on the WCF? Basically
It does not seem to be documented very much: hsh.merge(other_hash){|key, oldval, newval| block} →

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.