You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it make sense to derive Ord, Enum, and Bounded instances for Direction g? I am working on a game that should work in any grid and it seems to me that "turning left," for example, is well defined in all grids and could be defined in terms of Enum and Bounded. Or perhaps some other functionality could be added for iterating through directions, maybe with a different type class?
The text was updated successfully, but these errors were encountered:
Nice! I've been working with a local copy where I simply derive them for each internal Direction type. But maybe a custom type class, i.e. Rotate, would make more sense semantically?
Also, I'm not sure if there is some way to make the Grid class enforce these (and other, such as Eq) constraints on the Index and Direction types? I've been writing code that works on arbitrary grids and my type signatures include constraints like
where it would be great to just write Grid g, since I don't see a case where, for example, indices and directions wouldn't be comparable or directions wouldn't be rotatable. I'm still learning Haskell though so maybe there is already a way around this?
Would it make sense to derive
Ord
,Enum
, andBounded
instances forDirection g
? I am working on a game that should work in any grid and it seems to me that "turning left," for example, is well defined in all grids and could be defined in terms ofEnum
andBounded
. Or perhaps some other functionality could be added for iterating through directions, maybe with a different type class?The text was updated successfully, but these errors were encountered: