BuildExpression.hs 1.81 KB
Newer Older
1 2
{-# LANGUAGE FlexibleInstances, FlexibleContexts, MultiParamTypeClasses #-}

Andrey Mokhov's avatar
Andrey Mokhov committed
3 4 5 6 7 8 9 10 11 12 13 14 15
module Expression.BuildExpression (
    BuildExpression,
    Ways, Packages, TargetDirs,

    -- reexport from Expression.PG:
    bimap, (|>), (?), (??), whenExists, support,
    msum, mproduct,
    fromList, fromOrderedList
    ) where

import Base
import Ways
import Package (Package)
16
import Oracles.Builder
Andrey Mokhov's avatar
Andrey Mokhov committed
17
import Expression.PG
18
import Expression.Project
Andrey Mokhov's avatar
Andrey Mokhov committed
19 20 21 22 23 24 25
import Expression.BuildPredicate

type BuildExpression v = PG BuildPredicate v

type Ways       = BuildExpression Way
type Packages   = BuildExpression Package
type TargetDirs = BuildExpression TargetDir
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

-- Projecting a build expression requires examining all predicates and vertices
instance (Project Package v, Project Package BuildPredicate)
    => Project Package (BuildExpression v) where
    project p = bimap (project p) (project p)

instance (Project Builder v, Project Builder BuildPredicate)
    => Project Builder (BuildExpression v) where
    project b = bimap (project b) (project b)

instance (Project (Stage -> Builder) v,
    Project (Stage -> Builder) BuildPredicate)
    => Project (Stage -> Builder) (BuildExpression v) where
    project s2b = bimap (project s2b) (project s2b)

instance (Project Stage v, Project Stage BuildPredicate)
    => Project Stage (BuildExpression v) where
    project s = bimap (project s) (project s)

instance (Project TargetDir v, Project TargetDir BuildPredicate)
    => Project TargetDir (BuildExpression v) where
    project d = bimap (project d) (project d)

instance (Project Way v, Project Way BuildPredicate)
    => Project Way (BuildExpression v) where
    project w = bimap (project w) (project w)

instance (Project FilePath v, Project FilePath BuildPredicate)
    => Project FilePath (BuildExpression v) where
    project f = bimap (project f) (project f)