Automatic inference of an instance using newtype

(A related question Even more generalized new type inference )

I like the wrapper types

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype Foo = Foo { unFoo :: Int } deriving (Eq, Ord, Enum, Real, Num, Read, Integral, Show)
newtype Var = Var { unVar :: Int } deriving (Eq, Ord, Enum, Real, Num, Read, Integral, Show)

      

to prevent

doSomething :: Int -> Int -> Int
doSomething someFoo otherVar

      

Is it possible to automatically get all possible instances?

(Not recommended ?, Is there a better way?)

Thank!

+3
haskell


source to share


No one has answered this question yet

See similar questions:

nine
Even more generalized new type inference

or similar:

277
What does the `forall` keyword do in Haskell / GHC?
147
Difference between `data` and` newtype` in Haskell
122
Why does Haskell have "data" and a "new type"?
7
Is there a way to get binary instances for vinyl record types using Derive and Template Haskell or otherwise
6
Automatic output of Data.Vector.Unbox with associated type synonyms
4
Instance of type class is not used when getting data structure
2
How to "make makeData" a "new type"?
2
Analysis error while reading
2
haskell enum - what to do when value constructors require a value instead of zero? Demand scenario
1
A new type that outputs IsSequence



All Articles
Loading...
X
Show
Funny
Dev
Pics