diff --git a/src/System/Console/Terminal/Color.hs b/src/System/Console/Terminal/Color.hs index 805e8b6..1a4b167 100644 --- a/src/System/Console/Terminal/Color.hs +++ b/src/System/Console/Terminal/Color.hs @@ -53,7 +53,7 @@ class AsColor p f t where -- '_Color' :: 'Iso'' 'ANSI.Color' 'Color' -- '_Color' :: 'Prism'' 'Terminfo.Color' 'Color' -- @ - _Color :: Overloaded' p f t Color + _Color :: Optic' p f t Color -- | -- @ @@ -61,16 +61,16 @@ class AsColor p f t where -- '_Red' :: 'Prism'' 'Color' () -- ... -- @ - _Black, _Red, _Green, _Yellow, _Blue, _Magenta, _Cyan, _White :: (Choice p, Applicative f) => Overloaded' p f t () + _Black, _Red, _Green, _Yellow, _Blue, _Magenta, _Cyan, _White :: (Choice p, Applicative f) => Optic' p f t () - _Black = _Color.eq Black - _Red = _Color.eq Red - _Green = _Color.eq Green - _Yellow = _Color.eq Yellow - _Blue = _Color.eq Blue - _Magenta = _Color.eq Magenta - _Cyan = _Color.eq Cyan - _White = _Color.eq White + _Black = _Color.only Black + _Red = _Color.only Red + _Green = _Color.only Green + _Yellow = _Color.only Yellow + _Blue = _Color.only Blue + _Magenta = _Color.only Magenta + _Cyan = _Color.only Cyan + _White = _Color.only White instance AsColor p f Color where _Color = id @@ -95,14 +95,14 @@ instance (Choice p, Applicative f) => AsColor p f Terminfo.Color where seta Terminfo.Cyan = Just Cyan seta Terminfo.White = Just White seta Terminfo.ColorNumber{} = Nothing - _Black = eq Terminfo.Black - _Red = eq Terminfo.Red - _Green = eq Terminfo.Green - _Yellow = eq Terminfo.Yellow - _Blue = eq Terminfo.Blue - _Magenta = eq Terminfo.Magenta - _Cyan = eq Terminfo.Cyan - _White = eq Terminfo.White + _Black = only Terminfo.Black + _Red = only Terminfo.Red + _Green = only Terminfo.Green + _Yellow = only Terminfo.Yellow + _Blue = only Terminfo.Blue + _Magenta = only Terminfo.Magenta + _Cyan = only Terminfo.Cyan + _White = only Terminfo.White #endif instance (Profunctor p, Functor f) => AsColor p f ANSI.Color where diff --git a/src/System/Console/Terminal/Intensity.hs b/src/System/Console/Terminal/Intensity.hs index caee165..2c7b13c 100644 --- a/src/System/Console/Terminal/Intensity.hs +++ b/src/System/Console/Terminal/Intensity.hs @@ -42,7 +42,7 @@ class AsIntensity p f t where -- '_Intensity' :: 'Equality'' 'Intensity' 'Intensity' -- '_Intensity' :: 'Iso'' 'ANSI.ColorIntensity' 'Intensity' -- @ - _Intensity :: Overloaded' p f t Intensity + _Intensity :: Optic' p f t Intensity -- | -- @ @@ -50,10 +50,10 @@ class AsIntensity p f t where -- '_Vivid' :: 'Prism'' 'Intensity' () -- ... -- @ - _Dull, _Vivid :: (Choice p, Applicative f) => Overloaded' p f t () + _Dull, _Vivid :: (Choice p, Applicative f) => Optic' p f t () - _Dull = _Intensity.eq Dull - _Vivid = _Intensity.eq Vivid + _Dull = _Intensity.only Dull + _Vivid = _Intensity.only Vivid instance AsIntensity p f Intensity where _Intensity = id diff --git a/src/System/Console/Terminal/Util.hs b/src/System/Console/Terminal/Util.hs index 37c3023..8cfcf2e 100644 --- a/src/System/Console/Terminal/Util.hs +++ b/src/System/Console/Terminal/Util.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE Rank2Types #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} ----------------------------------------------------------------------------- @@ -14,15 +15,11 @@ -- This internal module provides some combinators that help write prisms. ---------------------------------------------------------------------------- module System.Console.Terminal.Util - ( eq - , en + ( en ) where +import Data.Function import Control.Lens -eq :: Eq a => a -> Prism' a () -eq a = prism' (const a) $ \b -> if a == b then Just () else Nothing - en :: Enum a => a -> Prism' a () -en a = prism' (const a) $ \b -> if fromEnum a == fromEnum b then Just () else Nothing - +en a = nearly a (((==) `on` fromEnum) a) diff --git a/terminal.cabal b/terminal.cabal index 789fd60..15bea4d 100644 --- a/terminal.cabal +++ b/terminal.cabal @@ -42,7 +42,7 @@ library base >= 4.4 && < 5, data-default >= 0.4 && < 0.5, ghc-prim, - lens >= 3.8, + lens >= 4, mtl >= 2 && < 2.2, transformers >= 0.2.2 && < 0.4