Skip to content

Columnable for newtype #227

Description

@guibou

Is your feature request related to a problem? Please describe.

I'm working with a lot of newtype on top of numeric types, (e.g. Double, Int, ...), and I recently got confused by fromAny which does not behave as expected with them, e.g, it returns Nothing.

ghci> Right df <- fromCsv "a,b,c\n1.3,2.5,7.2"
ghci> newtype BetterDouble = BetterDouble Double deriving (Show, Eq, Ord)
ghci> fromAny (snd $ head (head (toRowList df)))  :: Maybe Double
Just 1.3
ghci> fromAny (snd $ head (head (toRowList df)))  :: Maybe BetterDouble
Nothing

Describe the solution you'd like

Having a way to either extend, or add support for anything coercible to Double

Describe alternatives you've considered

For now, I'm using fromAny @Double followed by coerce, but I got surprised and I don't like surprise ;)

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions