Sunday, 15 June 2014

haskell - Two instance of the same type class for the same type -



haskell - Two instance of the same type class for the same type -

imagine have haskell programme uses library. programme provides typeclass tc instance type t 1 of dependencies. in next version of same library, library authors provided instance of typeclass tc type t.

we want utilize both of typeclass instances. how can so?

p.s. newtype solution won't work. both instances reside in libraries don't control.

p.p.s. don't have illustration of real code. it's theoretical question. want larn how type classes work library composability.

the haskell 2010 study §4.3.2 states that

a type may not declared instance of particular class more 1 time in program.

so not possible in standard haskell.

i not aware of ghc extension allow in ghc.

this (one?) reason why orphan instances (defining instance in different module both type , typeclass) considered bad idea.

haskell types typeclass

No comments:

Post a Comment