Especially useful for numeric types:
integerToNatural :: Integer -> Maybe Natural
integerToInt :: Integer -> Maybe Int
intToWord :: Int -> Maybe Word
wordToInt :: Word -> Maybe Int
Maybe there could be some abstraction for such kind of things that can looks like this:
class PartialProjection small big where
widen :: small -> big
shorten :: big -> Maybe small
Or even generalise this construction to be able to have Maybe or not have it in both directions.
Looks like Prism but dunno. To be discussed.
Especially useful for numeric types:
Maybe there could be some abstraction for such kind of things that can looks like this:
Or even generalise this construction to be able to have
Maybeor not have it in both directions.Looks like
Prismbut dunno. To be discussed.