{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Utxow () where

import Cardano.Ledger.Conway.Core (AlonzoEraScript (..), AsItem, AsIx, Era, EraRule, EraTxCert (..))
import Cardano.Ledger.Conway.Rules (ConwayUtxowPredFailure, PredicateFailure)
import Test.Cardano.Ledger.Conformance (
  OpaqueErrorString (..),
  SpecTranslate (..),
  showOpaqueErrorString,
 )
import Test.Cardano.Ledger.Conway.TreeDiff (ToExpr)

import Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Utxo ()

instance
  ( Era era
  , ToExpr (PlutusPurpose AsIx era)
  , ToExpr (PlutusPurpose AsItem era)
  , ToExpr (PredicateFailure (EraRule "UTXO" era))
  , ToExpr (TxCert era)
  ) =>
  SpecTranslate ctx (ConwayUtxowPredFailure era)
  where
  type SpecRep (ConwayUtxowPredFailure era) = OpaqueErrorString

  toSpecRep :: ConwayUtxowPredFailure era
-> SpecTransM ctx (SpecRep (ConwayUtxowPredFailure era))
toSpecRep = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToExpr a => a -> OpaqueErrorString
showOpaqueErrorString