4 ms·
Perhaps are you looking for Sum Types?[0] They let you group several types into a unifying type, e.g. a Shape is a Circle, Square, or Triangle, then you can use
by JackMorgan 5y ago
Perhaps are you looking for Sum Types?[0] They let you group several types into a unifying type, e.g. a Shape is a Circle, Square, or Triangle, then you can use pattern matching to have different behavior for each. This example is in F# [1] but it's almost exactly the same as it would be in Haskell.
[0]https://www.schoolofhaskell.com/user/Gabriel439/sum-types https://www.schoolofhaskell.com/user/Gabriel439/sum-types
[1]http://deliberate-software.com/christmas-f-number-polymorphism/ http://deliberate-software.com/christmas-f-number-polymorphi...