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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:47:01+00:00 2026-05-23T21:47:01+00:00

The ArrowList class from the hxt package has the following declaration: class (Arrow a,

  • 0

The ArrowList class from the hxt package has the following declaration:

class (Arrow a, ArrowPlus a, ArrowZero a, ArrowApply a) => ArrowList a where …

The ArrowPlus class is declared as:
class ArrowZero a => ArrowPlus a where …

The ArrowZero class is declared as:
class Arrow a => ArrowZero a where …

And the ArrowApply class is declared as:
class Arrow a => ArrowApply a where …

Why can’t it just be written as:
class (ArrowPlus a, ArrowApply a) => ArrowList a where …?

  • 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-23T21:47:02+00:00Added an answer on May 23, 2026 at 9:47 pm

    No, it’s not necessary to include all the superclasses. If you write

    class (ArrowPlus a, ArrowApply a) => ArrowList a where
    

    it will work. However, here are two possible reasons for mentioning all the superclasses explicitly.

    1. It might be more readable as you can tell at a glance what all the superclasses are.

    2. It might be slightly more efficient, as listing the superclasses explicitly will result in a direct dictionary lookup at runtime, while for a transitive superclass it will first lookup the dictionary for the superclass and then lookup the class member in that.

      For example, take this inheritance chain:

      module Example where
      
      class Foo a where
          foo :: a -> String
      
      class Foo a => Bar a
      class Bar a => Baz a
      class Baz a => Xyzzy a
      
      quux :: Xyzzy a => a -> String
      quux = foo
      

      Looking at the generated core for this (with ghc -c -ddump-simpl), we see that this generates a chain of lookup calls. It first looks up the dictionary for Baz in Xyzzy, then Bar in that, then Foo, and finally it can look up foo.

      Example.quux
        :: forall a_abI. Example.Xyzzy a_abI => a_abI -> GHC.Base.String
      [GblId, Arity=1, Caf=NoCafRefs]
      Example.quux =
        \ (@ a_acE) ($dXyzzy_acF :: Example.Xyzzy a_acE) ->
          Example.foo
            @ a_acE
            (Example.$p1Bar
               @ a_acE
               (Example.$p1Baz @ a_acE (Example.$p1Xyzzy @ a_acE $dXyzzy_acF)))
      

      Modifying the definition of Xyzzy to explicitly mention Foo:

      class (Foo a, Baz a) => Xyzzy a
      

      We see that it can now get the Foo dictionary straight from the Xyzzy one and look up foo in that.

      Example.quux
        :: forall a_abD. Example.Xyzzy a_abD => a_abD -> GHC.Base.String
      [GblId, Arity=1, Caf=NoCafRefs]
      Example.quux =
        \ (@ a_acz) ($dXyzzy_acA :: Example.Xyzzy a_acz) ->
          Example.foo @ a_acz (Example.$p1Xyzzy @ a_acz $dXyzzy_acA)
      

      Note that this may be GHC-specific. Tested with version 7.0.2.

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

Sidebar

Related Questions

The quoted code snippet from the JDK 7 java.util.ArrayList class confuses me. I can't
Coming from Java and using the ArrayList class has me all frustrated when trying
I want to inherit from some kind of array/vector/list class so that I can
I have an arraylist which has a class datastructure. public class empRec { public
What's the explanation for the following: public class GenericsTest { //statement 1 public ArrayList<Integer>[]
When running the following class the ExecutionService will often deadlock. import java.util.ArrayList; import java.util.Collection;
I'm confused by the following code: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
I am trying to use the ImageLoader class from libs-for-android (http://code.google.com/p/libs-for-android/), and am getting
Assume a class (for instance URI) that is convertable to and from a String

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.