treewide: add and apply stylish-haskell
Link: https://github.com/danth/stylix/pull/519
This commit is contained in:
parent
4ceede7504
commit
439c6cf24e
6 changed files with 39 additions and 36 deletions
|
|
@ -101,6 +101,7 @@
|
|||
hooks = {
|
||||
deadnix.enable = true;
|
||||
statix.enable = true;
|
||||
stylish-haskell.enable = true;
|
||||
typos.enable = true;
|
||||
yamllint.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
module Ai.Evolutionary ( Species(..), evolve ) where
|
||||
|
||||
import Data.Ord ( Down(Down), comparing )
|
||||
import Data.Vector ( (!) )
|
||||
import qualified Data.Vector as V
|
||||
import Data.Vector.Algorithms.Intro ( selectBy )
|
||||
import System.Random ( randomRIO )
|
||||
import Text.Printf ( printf )
|
||||
import Data.Ord (Down (Down), comparing)
|
||||
import Data.Vector ((!))
|
||||
import qualified Data.Vector as V
|
||||
import Data.Vector.Algorithms.Intro (selectBy)
|
||||
import System.Random (randomRIO)
|
||||
import Text.Printf (printf)
|
||||
|
||||
numSurvivors :: Int
|
||||
numSurvivors = 500
|
||||
|
|
@ -96,7 +96,7 @@ selectSurvivors environment population =
|
|||
shouldContinue :: [Double] -- ^ Fitness history
|
||||
-> Bool
|
||||
shouldContinue (x:y:_) = x /= y
|
||||
shouldContinue _ = True
|
||||
shouldContinue _ = True
|
||||
|
||||
evolutionLoop :: Species e g
|
||||
=> e -- ^ Environment
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
module Data.Colour ( LAB(..), RGB(..), deltaE, lab2rgb, rgb2lab ) where
|
||||
|
||||
data LAB = LAB { lightness :: Double
|
||||
, channelA :: Double
|
||||
, channelB :: Double
|
||||
, channelA :: Double
|
||||
, channelB :: Double
|
||||
}
|
||||
|
||||
data RGB = RGB { red :: Double
|
||||
data RGB = RGB { red :: Double
|
||||
, green :: Double
|
||||
, blue :: Double
|
||||
, blue :: Double
|
||||
}
|
||||
|
||||
-- Based on https://github.com/antimatter15/rgb-lab/blob/master/color.js
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import Ai.Evolutionary ( evolve )
|
||||
import Codec.Picture ( DynamicImage, convertRGB8, readImage )
|
||||
import Data.Colour ( lab2rgb )
|
||||
import qualified Data.Vector as V
|
||||
import Stylix.Output ( makeOutputTable )
|
||||
import Stylix.Palette ( )
|
||||
import System.Environment ( getArgs )
|
||||
import System.Exit ( die )
|
||||
import System.Random ( setStdGen, mkStdGen )
|
||||
import Text.JSON ( encode )
|
||||
import Ai.Evolutionary (evolve)
|
||||
import Codec.Picture (DynamicImage, convertRGB8, readImage)
|
||||
import Data.Colour (lab2rgb)
|
||||
import qualified Data.Vector as V
|
||||
import Stylix.Output (makeOutputTable)
|
||||
import Stylix.Palette ()
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit (die)
|
||||
import System.Random (mkStdGen, setStdGen)
|
||||
import Text.JSON (encode)
|
||||
|
||||
-- | Load an image file.
|
||||
loadImage :: String -- ^ Path to the file
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
module Stylix.Output ( makeOutputTable ) where
|
||||
|
||||
import Data.Colour ( RGB(RGB) )
|
||||
import Data.Colour (RGB (RGB))
|
||||
import qualified Data.Vector as V
|
||||
import Data.Word ( Word8 )
|
||||
import Text.JSON ( JSObject, toJSObject )
|
||||
import Text.Printf ( printf )
|
||||
import Data.Word (Word8)
|
||||
import Text.JSON (JSObject, toJSObject)
|
||||
import Text.Printf (printf)
|
||||
|
||||
toHexNum :: Double -> Word8
|
||||
toHexNum = truncate
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
|
||||
module Stylix.Palette ( ) where
|
||||
|
||||
import Ai.Evolutionary ( Species(..) )
|
||||
import Codec.Picture ( Image(imageWidth, imageHeight), PixelRGB8(PixelRGB8), pixelAt )
|
||||
import Data.Colour ( LAB(lightness), RGB(RGB), deltaE, rgb2lab )
|
||||
import Data.List ( delete )
|
||||
import Data.Vector ( (//) )
|
||||
import qualified Data.Vector as V
|
||||
import System.Random ( randomRIO )
|
||||
import Ai.Evolutionary (Species (..))
|
||||
import Codec.Picture (Image (imageHeight, imageWidth),
|
||||
PixelRGB8 (PixelRGB8), pixelAt)
|
||||
import Data.Colour (LAB (lightness), RGB (RGB), deltaE, rgb2lab)
|
||||
import Data.List (delete)
|
||||
import Data.Vector ((//))
|
||||
import qualified Data.Vector as V
|
||||
import System.Random (randomRIO)
|
||||
|
||||
-- | Extract the primary scale from a palette.
|
||||
primary :: V.Vector a -> V.Vector a
|
||||
|
|
@ -73,9 +75,9 @@ instance Species (String, Image PixelRGB8) (V.Vector LAB) where
|
|||
|
||||
scheme = case polarity of
|
||||
"either" -> min lightScheme darkScheme
|
||||
"light" -> lightScheme
|
||||
"dark" -> darkScheme
|
||||
_ -> error ("Invalid polarity: " ++ polarity)
|
||||
"light" -> lightScheme
|
||||
"dark" -> darkScheme
|
||||
_ -> error ("Invalid polarity: " ++ polarity)
|
||||
|
||||
{-
|
||||
For light themes, the background is bright and the text is dark.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue