Skip to content

Commit

Permalink
fix partiality warning
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Dec 18, 2024
1 parent f17501b commit ff3068d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Data/Colour/Palette/RandomColor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Data.Colour.Palette.Types
import Data.Colour.RGBSpace.HSV
import Data.Colour.SRGB (RGB (..), sRGB)
import Data.List (find)
import qualified Data.List.NonEmpty as NE
import Data.Maybe (fromMaybe)

getColorDefinition :: Hue -> ColorDefinition
Expand Down Expand Up @@ -106,9 +107,9 @@ saturationRange :: Hue -> (Int, Int)
saturationRange hue = result
where
lbs = lowerBounds $ getColorDefinition hue
result = case lbs of
[] -> error "Can\'t obtain saturationRange from an empty lowerBounds"
_ -> (fst . head $ lbs, fst . last $ lbs)
result = case NE.nonEmpty lbs of
Nothing -> error "Can\'t obtain saturationRange from an empty lowerBounds"
Just lbsNE -> (fst . NE.head $ lbsNE, fst . NE.last $ lbsNE)

randomSaturation :: MonadRandom m => Hue -> Luminosity -> m Int
randomSaturation HueMonochrome _ = return 0
Expand Down

0 comments on commit ff3068d

Please sign in to comment.