I'm writing a snake game in Haskell. These are some of the things I have:
- A
Coord
data type - A
Line
data type - A
Rect
data type - A
Polygon
type class, which allows me to get aRect
as a series of lines ([Line]
). - An
Impassable
type class that allows me to get aLine
as a series of Coords ([Coord]
) so that I can detect collisions between otherImpassable
s. - A
Draw
type class for anything that I want to draw to the screen (HSCurses). - Finally I'm using QuickCheck so I want to declare
Arbitrary
instances for a lot of these things.
Currently I have a lot of these in separate modules so I have lots of small modules. I've noticed that I have to import a lot of them for each other so I'm kind of wondering what the point was.
I'm particularly confused about Arbitrary
instances. When using -Wall
I get warnings about orphaned instances when I but those instances together in one test file, my understanding is that I can avoid that warning by putting those instances in the same module as where the data type is defined but then I'll need to import Test.QuickCheck
for all those modules which seems silly because QuickCheck should only be required when building the test executable.
Any advice on the specific problem with QuickCheck would be appreciated as would guidance on the more general problem of how/where programs should be divided into modules.