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

  • Home
  • SEARCH
  • 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 6111639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:13+00:00 2026-05-23T14:39:13+00:00

Functional languages often have Functor types/interfaces. In .NET a Functor interface would be an

  • 0

Functional languages often have Functor types/interfaces.

In .NET a Functor interface would be an Interface implementable by generic types (T<A>) that has a function called fmap that takes a function from the container type (A) to a different type (B) and returns an object with container type B.

For example a type List<A> would have a method List.fmap. The signature would be something like:

public List<B> fmap<B>(Func<A,B>);

Is it possible to create such an interface? Is it possible to do something similar? Are there any packages that provide an Interface like this and provide extension methods for obvious classes (List<T>, Dictionary<A,B>, Set<A>, etc.) ?

Update:

I know that IEnumerable objects almost do this. The key difference is that IEnumerable.Select returns an IEnumerable not the type of the implementer. For example, List.Select(A => B) returns IEnumerable not List. This shows why you can not implement IMappable in the obvious way for .NET, but is there a hack or extra type information you could use to effectively implement it?

  • 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-23T14:39:14+00:00Added an answer on May 23, 2026 at 2:39 pm

    Okay, based on the comment, I suspect the answer’s no – you’d need higher-order generic types. You’d want something like:

    // Not real syntax!
    interface IFunctor<TFunctor<?>, TValue>
        where TFunctor<X> : IFunctor<TFunctor<X>, TValue>
    {
        TFunctor<TProjection> Project<TProjection>(Func<TValue, TProjection> func);
    }
    

    The problem is trying to express the idea that the implementation of the interface must also be generic in a particular way, and allow that generic relationship to be used in the rest of the interface. That’s not part of .NET generics, I’m afraid.

    Joe Duffy has written about wishing for higher-order types before now – unfortunately I can’t tell whether or not that article is relevant, as I can’t get to it at the moment. (His blog server is somewhat temporamently, but the content is great 🙂


    It’s not entirely clear, but it’s possible you’re just talking about LINQ to Objects, basically. For example:

    var kids = people.Where(x => x.Age < 18) // Filtering
                     .Select(x => x.Name)    // Projection
                     .ToList();
    

    You could write a more general purpose interface, e.g.

    public interface IFunctor<T>
    {
        IFunctor<TOther> Foo<TOther>(Func<T, TOther> selector);
    }
    

    … but there’s no such interface actually implemented by List<T> etc. LINQ to Objects works via extension methods instead.

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

Sidebar

Related Questions

Using pure functional languages can have a lot of benefits over using impure imperatives,
It is known that all functional languages share some basic properties like using functions
Do any of the current crop of popular functional languages have good support for
I've often heard that functional programming solves a lot of problems that are difficult
I have often wondered why it is that non-English speaking programmers are forced to
We have a non-Unicode, C++ application, written with Visual Studio, that has been originally
When you pass a callback in some form to another function, you often have
Functional languages are good because they avoid bugs by eliminating state, but also because
Functional languages lead to use of recursion to solve a lot of problems, and
I know of several functional languages - F#, Lisp and its dialects, R, and

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.