Which do you suggest:
data Direction = Left | Right
type Direction = Bool
newtype Direction = Direction Bool
Then I'm making:
data Move = WalkRight Bool | Jump
or
data Move = Walk Direction | Jump
depending of the previous answer.
I have a function of type Char -> Maybe Move:
charToAction 'q' = Just $ WalkRight False
charToAction 'd' = Just $ WalkRight True
charToAction 'z' = Just Jump
charToAction _ = Nothing
Should I change my type Move into:
data Move = Stationary | WalkRight Bool | Jump
? The function would become:
charToAction 'q' = WalkRight False
charToAction 'd' = WalkRight True
charToAction 'z' = Jump
charToAction _ = Stationary
I wonder this because the list doesn't need a Maybe:
data [a] = [] | a : [a]
Or is there a way to derive Maybe to make it cleaner?
WalkRight Falseisn't very suggestive of its intended meaning.data [a] = [] | a : [a], unlike what you've written.