-- SPDX-FileCopyrightText: 2022 Gan Shen
-- SPDX-FileCopyrightText: 2025 Alex Ionescu
-- SPDX-License-Identifier: MPL-2.0 AND BSD-3-Clause

{-# LANGUAGE ExplicitNamespaces #-}

-- | This module defines the interface to HasChor. The client of the library is
-- highly recommended to only use constructs exported by this module.
module Choreography (
  -- * Locations and Located Values
  LocTm,
  LocTy,
  type (@),
  mkLoc,

  -- * The Choreo monad
  Choreo,
  -- ** Choreo operations
  locally,
  (~>),
  (~~>),
  cond,
  cond',
  cond_,
  cond_',

  -- * Message transport backends
  -- ** The HTTP backend
  Host,
  Port,
  HttpConfig,
  mkHttpConfig,

  -- * Running choreographies
  runChoreo,
  runChoreography
  ) where

import Choreography.Location
import Choreography.Choreo
import Choreography.Network
import Choreography.Network.Http
import Control.Monad.IO.Class

-- | Run a choreography with a message transport backend.
runChoreography :: (Backend config, MonadIO m) => config -> Choreo m a -> LocTm -> m a
runChoreography :: forall config (m :: * -> *) a.
(Backend config, MonadIO m) =>
config -> Choreo m a -> LocTm -> m a
runChoreography config
cfg Choreo m a
choreo LocTm
l = config -> LocTm -> Network m a -> m a
forall c (m :: * -> *) a.
(Backend c, MonadIO m) =>
c -> LocTm -> Network m a -> m a
forall (m :: * -> *) a.
MonadIO m =>
config -> LocTm -> Network m a -> m a
runNetwork config
cfg LocTm
l ([LocTm] -> Choreo m a -> LocTm -> Network m a
forall (m :: * -> *) a.
[LocTm] -> Choreo m a -> LocTm -> Network m a
epp (config -> [LocTm]
forall c. Backend c => c -> [LocTm]
locs config
cfg) Choreo m a
choreo LocTm
l)