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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:28:45+00:00 2026-05-14T04:28:45+00:00

This question is for the people who know both Haskell (or any other functional

  • 0

This question is for the people who know both Haskell (or any other functional language that supports Higher-kinded Types) and C++…

Is it possible to model higher kinded types using C++ templates? If yes, then how?

EDIT :

From this presentation by Tony Morris:

Higher-order Polymorphism :

  • Languages such as Java and C# have
    first-order polymorphism because they
    allow us to abstract on types. e.g.
    List<A> can have a reverse function
    that works on any element type (the
    A).

  • More practical programming languages
    and type systems allow us to
    abstract on type constructors as
    well.

  • This feature is called higher-order
    (or higher-kinded) polymorphism.

Example :

Pseudo-Java with an invented notation for higher-order polymorphism

interface Transformer<X, Y> {
  Y transform(X x);
}

interface Monad<M> { // M :: * -> *
  <A> M<A> pure(A a);
  <A, B> M<B> bind(Transformer<A, M<B>> t, M<A> a);
}
  • 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-14T04:28:46+00:00Added an answer on May 14, 2026 at 4:28 am

    Template-template parameters?

    template <template <typename> class m>
    struct Monad {
        template <typename a>
        static m<a> mreturn(const a&);
        
        template <typename a, typename b>
        static m<b> mbind(const m<a>&, m<b>(*)(const a&));
    };
    
    template <typename a>
    struct Maybe {
        bool isNothing;
        a value;
    };
    
    template <>
    struct Monad<Maybe> {
        template <typename a>
        static Maybe<a> mreturn(const a& v) {
            Maybe<a> x;
            x.isNothing = false;
            x.value = v;
            return x;
        }
        
        template <typename a, typename b>
        static Maybe<b> mbind(const Maybe<a>& action, Maybe<b>(*function)(const a&)) {
            if (action.isNothing)
                return Maybe<b>{true, b{}};
            else
                return function(action.value);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've all seen people who do this: jQuery('a').each(function(){ jQuery(this)[0].innerHTML += ' proccessed'; }); function
Ok, I think this question is at the wrong place and I'll head over
Ok, I know that serving media files through Django is a not recommended .
I mean I understand that these templates are aimed at designers and other less
I maybe asking a dumb question, but I looked at the wikipedia page for
I have an external website that uses Active Directory for Authentication . The propsed
I want to find out more about NoSQL databases/data-stores available for use from Java,
Summary I'm a seasoned programmer with years of experience in Windows Forms development using
How do you optimised a website for the search engines? As far as I
I am concerned about buffer overflows, and I need to get some characters out

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.