Generalize elemOfString into elemOf'
This commit is contained in:
parent
08fc0f30e4
commit
43f2cef419
|
@ -7,7 +7,7 @@ module Function
|
|||
, fileComponents
|
||||
, lowerString
|
||||
, elemOf
|
||||
, elemOfString
|
||||
, elemOf'
|
||||
, makeTemplate
|
||||
, applyTemplate
|
||||
, toText
|
||||
|
@ -79,10 +79,12 @@ lowerString :: TokenableTo String a => a -> DepGenM (Token String)
|
|||
lowerString a = runFunction LowerString =<< toToken a
|
||||
|
||||
|
||||
class (Show w, Lift w) => WitnessFor w t | w -> t
|
||||
class (Show w, Lift w) => WitnessFor w t | w -> t, t -> w where
|
||||
witnessValue :: w
|
||||
|
||||
data StringType = StringType deriving (Show, Lift)
|
||||
instance WitnessFor StringType String
|
||||
instance WitnessFor StringType String where
|
||||
witnessValue = StringType
|
||||
|
||||
data ElemOf a where ElemOf :: WitnessFor w a => w -> ElemOf a
|
||||
deriving instance Show (ElemOf a)
|
||||
|
@ -93,8 +95,8 @@ instance (Show a, Lift a, Valuable a, Eq a) => IsFunction (ElemOf a) (a, [a]) Bo
|
|||
elemOf :: (Show t, Lift t, Valuable t, Eq t, TokenableTo t a, TokenableTo [t] b, WitnessFor w t) => w -> a -> b -> DepGenM (Token Bool)
|
||||
elemOf witness a b = runFunction (ElemOf witness) =<< toTupleToken a b
|
||||
|
||||
elemOfString :: (TokenableTo String a, TokenableTo [String] b) => a -> b -> DepGenM (Token Bool)
|
||||
elemOfString = elemOf StringType
|
||||
elemOf' :: (Show t, Lift t, Valuable t, Eq t, WitnessFor w t, TokenableTo t a, TokenableTo [t] b) => a -> b -> DepGenM (Token Bool)
|
||||
elemOf' = elemOf witnessValue
|
||||
|
||||
|
||||
data MakeTemplate = MakeTemplate deriving (Show, Lift)
|
||||
|
|
|
@ -17,7 +17,7 @@ copyTo path targetDir = do
|
|||
hasExtension :: (TokenableTo [String] a, TokenableTo FilePath b) => a -> b -> DepGenM (Token Bool)
|
||||
hasExtension exts filename = do
|
||||
ext <- lowerString =<< untupleSndDepGenM =<< fileComponents filename
|
||||
ext `elemOfString` exts
|
||||
ext `elemOf'` exts
|
||||
|
||||
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM ()
|
||||
handleRecipeDir outputDir htmlTemplate indexName dir = do
|
||||
|
|
Loading…
Reference in New Issue