Skip to content

Add newtype combinators to lift binary operations over newtype #61

@chshersh

Description

@chshersh

Like these ones:

ghci> import Data.Coerce 
ghci> :set -XScopedTypeVariables 
ghci> :set -XTypeApplications 
ghci> :{
ghci| via :: forall n a . Coercible a n => (n -> n -> n) -> (a -> a -> a)
ghci| via = coerce
ghci| :}
ghci> :{
ghci| viaF :: forall n a . Coercible a (n a) => (n a -> n a -> n a) -> (a -> a -> a)
ghci| viaF = coerce
ghci| :}
ghci> via @(Sum Int) @Int (<>) 3 4
7
ghci> viaF @Sum @Int (<>) 3 5
8

Metadata

Metadata

Assignees

Labels

newBring something new into library (add function or type or interface)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions