summaryrefslogtreecommitdiff
path: root/src/WWW/Colors/Hex.hs
blob: 1773e66480b17b3e7eed40a8fbb23c55155afe4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE TemplateHaskell #-}
module WWW.Colors.Hex
    ( HexColor
    ) where

import Data.Colour
import Digrams.Attributes
import Language.Haskell.TH.Quote


newtype HexColor = HexColor ByteString
    deriving (Eq, Generic, Ord)

instance Bounded HexColor where
    maxBound = HexColor "\255\255\255"
    minBound = HexColor "\NUL\NUL\NUL"


instance Color HexColor where




hex :: QuasiQuoter
hex = QuasiQuoter
    { quoteExp = parseit
    , quotePat = failure "quotePat"
    , quoteType = failure "quoteType"
    , quoteDec = failure "quoteDec"
    } where
        failure s = const $ fail $ "No " <> s <> " defined for the hexcolor quasiquoter."
        parseit s = case undefined of
                      Nothing -> fail $ "Can't understand " <> s <> " as a valid hex color."
                      Just h -> h `seq` [|h|]