module Horizon.Spec.Utils
  ( callHackage
  , callGit
  , callTarball
  , callLocal) where

import           Horizon.Spec.Types.GitSource      (GitSource (MkGitSource))
import           Horizon.Spec.Types.HackageSource  (HackageSource (MkHackageSource))
import           Horizon.Spec.Types.HaskellPackage (HaskellPackage,
                                                    mkHaskellPackage)
import           Horizon.Spec.Types.HaskellSource  (HaskellSource (FromGit, FromHackage, FromLocal, FromTarball))
import           Horizon.Spec.Types.LocalSource    (LocalSource (MkLocalSource))
import           Horizon.Spec.Types.Name           (Name)
import           Horizon.Spec.Types.Repo           (Repo)
import           Horizon.Spec.Types.Revision       (Revision)
import           Horizon.Spec.Types.Subdir         (Subdir)
import           Horizon.Spec.Types.TarballSource  (TarballSource (MkTarballSource))
import           Horizon.Spec.Types.Url            (Url)
import           Horizon.Spec.Types.Version        (Version)

callHackage :: Name -> Version -> HaskellPackage
callHackage :: Name -> Version -> HaskellPackage
callHackage Name
n = HaskellSource -> HaskellPackage
mkHaskellPackage forall b c a. (b -> c) -> (a -> b) -> a -> c
. HackageSource -> HaskellSource
FromHackage forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Version -> HackageSource
MkHackageSource Name
n

callGit :: Repo -> Revision -> Maybe Subdir -> HaskellPackage
callGit :: Repo -> Revision -> Maybe Subdir -> HaskellPackage
callGit Repo
u Revision
x Maybe Subdir
d = HaskellSource -> HaskellPackage
mkHaskellPackage forall b c a. (b -> c) -> (a -> b) -> a -> c
. GitSource -> HaskellSource
FromGit forall a b. (a -> b) -> a -> b
$ Repo -> Revision -> Maybe Subdir -> GitSource
MkGitSource Repo
u Revision
x Maybe Subdir
d

callTarball :: Url -> HaskellPackage
callTarball :: Url -> HaskellPackage
callTarball = HaskellSource -> HaskellPackage
mkHaskellPackage forall b c a. (b -> c) -> (a -> b) -> a -> c
. TarballSource -> HaskellSource
FromTarball forall b c a. (b -> c) -> (a -> b) -> a -> c
. Url -> TarballSource
MkTarballSource

callLocal :: Subdir -> HaskellPackage
callLocal :: Subdir -> HaskellPackage
callLocal = HaskellSource -> HaskellPackage
mkHaskellPackage forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocalSource -> HaskellSource
FromLocal forall b c a. (b -> c) -> (a -> b) -> a -> c
. Subdir -> LocalSource
MkLocalSource