Skip to content

Add partial conversion functions for converting between types #114

@chshersh

Description

@chshersh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnewBring something new into library (add function or type or interface)questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions