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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:42:47+00:00 2026-05-17T19:42:47+00:00

I just started learning Haskell and I ran into a problem in 2-adic type

  • 0

I just started learning Haskell and I ran into a problem in 2-adic type classes. Here’s the important code:

data Rectangle = NoRect | Rect (Float,Float) (Float,Float) | Pane
      deriving (Show)
class Collision s1 s2 where
      collides ::  s1 -> s2 -> Bool

instance (Collision Rectangle Rectangle) where
    collides (Rect (aOrX, aOrY) (aCorX, aCorY)) 
             (Rect (bOrX,bOrY) (bCorX,bCorY)) = ...
    collides Pane _ = True
    ...

The compiler (GHC 6.12.1) now complains about
Conflicting definitions for 'collides'

I don’t see, how the definitions would conflict, do you?

Thanks!

  • 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-17T19:42:48+00:00Added an answer on May 17, 2026 at 7:42 pm

    The most likely culprit is a layout error somewhere in your “…” that causes the two collides lines to be separated into two separate blocks. Conflicting definitions for 'collides' means that there are two different places in the same scope that are defining collides. Somehow either those two lines are interrupted so the compiler sees them as separate, or there’s an error in the “…” part that somehow defines collides twice in one scope.

    There are 2 main ways to trip the Conflicting definitions error. First, two bindings in the same function definition can try to bind the same variable, as in foo x x = .... That’s not allowed, because it defines x twice.

    The other (which is the one that I suspect applies in your code) is when two parts of the same definition are “interrupted” by another definition. The compiler sees that as two separate definitions. For example:

    foo True = ...
    bar = ...
    foo False = ...
    

    This is not allowed either, because it (again) defines the same name (foo) twice.

    The interruption may not be obvious, especially in cases where you accidentally mix tabs and spaces (and your editor uses something other than the 8 tabs per space that Haskell assumes). It can appear in your editor to be an indented line in a where clause but due to differences in tab width the compiler sees it aligned with foo, making the second foo into another definition conflicting with the first.

    It is generally considered a good idea in layout-sensitive languages to only use spaces in your code, or at the very least to make sure that your editor is using the right number of spaces for its tabs. For Haskell, that is 8.

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

Sidebar

Related Questions

I've just started learning Lisp and I can't figure out how to compile and
I've just started learning linq and lambda expressions, and they seem to be a
I have just started learning Erlang and am trying out some Project Euler problems
I'm just getting started with learning about Unit testing (and TDD in general). My
I have just started writing my own JavaScript Framework (just for the learning experience),
Just started getting a bunch of errors on our C# .Net app that seemed
Have just started using Google Chrome , and noticed in parts of our site,
I just started thinking about creating/customizing a web crawler today, and know very little
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using GNU Emacs as my text editor and I am concerned

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.