From a498e53bae93cdd100224d95218d64b71a00da6d Mon Sep 17 00:00:00 2001 From: Fyodor Soikin Date: Sun, 25 Feb 2024 12:51:04 -0500 Subject: [PATCH] Add type role annotation to Opt --- src/Data/Undefined/NoProblem.purs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Data/Undefined/NoProblem.purs b/src/Data/Undefined/NoProblem.purs index f77c424..f587056 100644 --- a/src/Data/Undefined/NoProblem.purs +++ b/src/Data/Undefined/NoProblem.purs @@ -29,17 +29,18 @@ derive newtype instance Show a => Show (Req a) -- | to omit such field when passing the parameter, but still allowing the -- | receiving function to work with the field. foreign import data Opt ∷ Type → Type +type role Opt representational -instance eqOpt ∷ Eq a ⇒ Eq (Opt a) where +instance Eq a ⇒ Eq (Opt a) where eq u1 u2 = toMaybe u1 == toMaybe u2 -instance eq1Opt ∷ Eq a ⇒ Eq1 Opt where +instance Eq a ⇒ Eq1 Opt where eq1 u1 u2 = eq1 (toMaybe u1) (toMaybe u2) -instance ordOpt ∷ Ord a ⇒ Ord (Opt a) where +instance Ord a ⇒ Ord (Opt a) where compare u1 u2 = toMaybe u1 `compare` toMaybe u2 -instance showOpt ∷ Show a ⇒ Show (Opt a) where +instance Show a ⇒ Show (Opt a) where show = maybe "undefined" ("Opt " <> _) <<< map show <<< toMaybe foreign import undefined ∷ ∀ a. Opt a