I'm new to Functional Programming. I've used Ramda a bit (JavaScript library), but nothing like the type system in Purescript.
I have an idea that I feel should be expressible with Purescript's type system, but I'm not really sure where to start.
Lets say I'm trying to define some types for a Sudoku Board
newtype Index = Index Int
newtype Column = Column Int
newtype Row = Row Int
newtype Box = Box Int
I'd like to define what addition looks like for these types
In sudocode:
indexAddition :: (Index | Int) -> (Index | Int) -> Index
indexAddition a b = (a + b) % 81
RowAddition :: (Row | Int) -> (Row | Int) -> Row
RowAddition a b = (a + b) % 9
ColumnAddition and BoxAddition can probably me merged with RowAddition since they're gonna be basically the same.
-- I have to be able to say that a is a subset of Int, but Int isn't a type class
FooAddition :: forall a. Int a => a -> a -> a
FooAddition a b = (a + b) % 9
I somehow feel like I'm likely starting off on the wrong foot here.
Any help?