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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:34:25+00:00 2026-06-17T19:34:25+00:00

I want to express that I have 3 related typeclasses. I have two files.

  • 0

I want to express that I have 3 related typeclasses.

I have two files. First:

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module ModA where

class Class a b c | a -> b, b -> c where
    getB :: a -> b
    getC :: b -> c

Second:

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module B where

import qualified ModA

data A = A {f1::String}

data B = B {f2::String}

data C = C {f3::String}

instance ModA.Class A B C where
    getB a = B "hey"
    getC a = C "ho"

getABForMe = ModA.getB (A "boo")

getACForMe = ModA.getC (B "yo")

The error I get:

No instance for (ModA.Class a0 B C)
  arising from a use of `ModA.getC'
Possible fix: add an instance declaration for (ModA.Class a0 B C)
In the expression: ModA.getC (B "yo")
In an equation for `getACForMe': getACForMe = ModA.getC (B "yo")

What am I missing?

  • 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-17T19:34:26+00:00Added an answer on June 17, 2026 at 7:34 pm

    You can make the functional dependency “circular”:

    class Class a b c | a->b, b->c, c->a where
        getB :: a -> b
        getC :: b -> c
    

    so any one type parameter can be deduced from any of the others. But I’m not sure if you really want this; why not have just a type class with one fundep and one method, and make two instances of it (instance Class A B and instance Class B C)?

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

Sidebar

Related Questions

I have an express app that I want to use the connect-form module on
I have a statement I want to express, that in C pseudo-code would look
My question is about a specific array operation that I want to express using
I'm working on a Node app that uses Express and SocketIO. I want to
Let's say I have a nodejs/express application on production server. If I want to
I want to create console application in Microsoft Visual C# 2010 Express that will
How can I express to PostgreSQL that I want values simultaneously from several hierarchical
I want to do a filter like rails before filter on express.js. I have
Say I have a set of Strings that I want to be ordered by
I want to compile a code that I have from long time ago using

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.