[Haskell-cafe] Deprecation cycle for classes
Jack Kelly
jack at jackkelly.name
Sat Jun 15 23:59:27 UTC 2019
Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> writes:
> I am unsure how to change the name of a class in a library whilst providing
> a safe deprecation cycle for the users of the library. Suppose I have
> version 1 of my library with a class
>
> -- Version 1
> class Foo a where
> foo :: a
>
> and I want to migrate it to version 3 as follows, but with a deprecation
> cycle provided by version 2 that allows code to work with either version 1
> and 2, or 2 and 3.
>
> -- Version 3
> class Bar a where
> bar :: a
What if you inserted Bar as a superclass of Foo in V2?
-- Version 1
class Foo a where
foo :: a
-- Version 2
{-# DEPRECATED Foo "it's going away in V3" #-}
class Bar a => Foo a where
foo :: a
class Bar a where
bar :: a
-- Version 3
class Bar a where
bar :: a
Users of version 1 can use Foo/foo/...
When they upgrade to version 2, they get forced to write a Bar instance,
get warned that Foo is going away, and they can use the class Bar to
implement their own instances.
Users of version 3 can only use Bar/bar/...
Does that help?
-- Jack
More information about the Haskell-Cafe
mailing list