{-# OPTIONS_GHC -fno-warn-unused-top-binds -fno-warn-orphans #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
module Language.ATS.Package.Type (
Pkg (..)
, ATSDependency (..)
, Bin (..)
, Lib (..)
, Src (..)
, Version (..)
, ForeignCabal (..)
, ATSConstraint (..)
, TargetPair (..)
, CCompiler (..)
, LibDep
, DepSelector
, dirLens
) where
import Data.Dependency
import Data.Hashable (Hashable)
import Development.Shake.ATS
import Language.ATS.Package.Debian
import Quaalude
data ATSConstraint = ATSConstraint { lower :: Maybe Version
, upper :: Maybe Version
}
deriving (Eq, Show, Generic, Binary, Interpret, Hashable)
deriving newtype instance Inject Version
type LibDep = (Text, ATSConstraint)
type DepSelector = ATSDependency -> [LibDep]
data PkgConfig = PkgConfig { dir :: Text, target :: Maybe Text }
data ATSDependency = ATSDependency { libName :: Text
, dir :: Text
, url :: Text
, description :: Maybe Text
, libVersion :: Version
, libDeps :: [LibDep]
, libBldDeps :: [LibDep]
, libCDeps :: [LibDep]
, script :: [Text]
}
deriving (Generic, Interpret, Binary, Hashable)
makeLensesFor [("dir", "dirLens")] ''ATSDependency
data TargetPair = TargetPair { hs :: Text
, ats :: Text
, cpphs :: Bool
} deriving (Generic, Interpret, Binary, Hashable)
deriving instance Interpret ForeignCabal
deriving instance Hashable Solver
deriving instance Interpret Solver
data Src = Src { atsSrc :: Text
, cTarget :: Text
, atsGen :: [TargetPair]
, extras :: [Text]
}
deriving (Generic, Interpret, Binary, Hashable)
data Bin = Bin { src :: Text
, target :: Text
, libs :: [Text]
, hsDeps :: [ForeignCabal]
, hs2ats :: [TargetPair]
, gcBin :: Bool
, extras :: [Text]
}
deriving (Generic, Interpret, Binary, Hashable)
data Lib = Lib { name :: Text
, src :: [Text]
, libTarget :: Text
, libs :: [Text]
, includes :: [Text]
, hsDeps :: [ForeignCabal]
, links :: [(Text, Text)]
, hs2ats :: [TargetPair]
, extras :: [Text]
, static :: Bool
}
deriving (Generic, Interpret, Binary, Hashable)
data Pkg = Pkg { bin :: [Bin]
, test :: [Bin]
, libraries :: [Lib]
, man :: Maybe Text
, completions :: Maybe Text
, version :: Version
, compiler :: Version
, dependencies :: [LibDep]
, clib :: [LibDep]
, buildDeps :: [LibDep]
, ccompiler :: Text
, cflags :: [Text]
, atsFlags :: [Text]
, atsSource :: [Src]
, dynLink :: Bool
, extSolve :: Solver
, debPkg :: Maybe Debian
, atsLib :: Bool
}
deriving (Generic, Interpret, Binary, Hashable)