Skip to content

Commit

Permalink
Simplify the Eq/Ord instances for FT
Browse files Browse the repository at this point in the history
While slightly more verbose, the new instance contexts avoid the need for
overlapping instances or `FlexibleContexts`.
  • Loading branch information
RyanGlScott committed Jun 26, 2022
1 parent 3bc5609 commit 33bcb24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
next [????.??.??]
-----------------
* Simplify the `Eq` and `Ord` instances for `FT` to avoid the use of
overlapping instances.

5.1.8 [2022.05.07]
------------------
* Generalize the `Monad` constraint in the type signatures for
Expand Down
15 changes: 12 additions & 3 deletions src/Control/Monad/Trans/Free/Church.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -97,10 +96,20 @@ instance ( Functor f, Monad m, Ord1 f, Ord1 m
compare1 x y = compare1 (fromFT x) (fromFT y)
#endif

instance (Eq1 (FT f m), Eq a) => Eq (FT f m a) where
instance ( Functor f, Monad m, Eq1 f, Eq1 m
# if !(MIN_VERSION_base(4,8,0))
, Functor m
# endif
, Eq a
) => Eq (FT f m a) where
(==) = eq1

instance (Ord1 (FT f m), Ord a) => Ord (FT f m a) where
instance ( Functor f, Monad m, Ord1 f, Ord1 m
# if !(MIN_VERSION_base(4,8,0))
, Functor m
# endif
, Ord a
) => Ord (FT f m a) where
compare = compare1

instance Functor (FT f m) where
Expand Down

0 comments on commit 33bcb24

Please sign in to comment.