{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans #-}

-- | This module implements QSM's @CanDiff@ typeclass using @tree-diff@'s
-- @ToExpr@.
module Test.Util.ToExpr () where

import           Data.TreeDiff as T
import qualified Test.StateMachine as QSM
import           Test.StateMachine.Diffing (CanDiff (..))
import qualified Test.StateMachine.Types.References as QSM

instance ToExpr x => CanDiff x where
  type ADiff  x = Edit EditExpr
  type AnExpr x = Expr

  toDiff :: x -> AnExpr x
toDiff             = x -> AnExpr x
x -> Expr
forall a. ToExpr a => a -> Expr
toExpr
  exprDiff :: Proxy x -> AnExpr x -> AnExpr x -> ADiff x
exprDiff         Proxy x
_ = AnExpr x -> AnExpr x -> ADiff x
Expr -> Expr -> Edit EditExpr
T.exprDiff
  diffToDocCompact :: Proxy x -> ADiff x -> Doc AnsiStyle
diffToDocCompact Proxy x
_ = ADiff x -> Doc AnsiStyle
Edit EditExpr -> Doc AnsiStyle
ansiWlBgEditExprCompact
  diffToDoc :: Proxy x -> ADiff x -> Doc AnsiStyle
diffToDoc        Proxy x
_ = ADiff x -> Doc AnsiStyle
Edit EditExpr -> Doc AnsiStyle
ansiWlBgEditExpr
  exprToDoc :: Proxy x -> AnExpr x -> Doc AnsiStyle
exprToDoc        Proxy x
_ = AnExpr x -> Doc AnsiStyle
Expr -> Doc AnsiStyle
ansiWlBgExpr

{-------------------------------------------------------------------------------
  QSM's References instances
-------------------------------------------------------------------------------}

instance ToExpr (r k) => ToExpr (QSM.Reference k r)

instance ToExpr a => ToExpr (QSM.Concrete a) where
  toExpr :: Concrete a -> Expr
toExpr (QSM.Concrete a
x) = a -> Expr
forall a. ToExpr a => a -> Expr
toExpr a
x

instance ToExpr (QSM.Opaque a) where
  toExpr :: Opaque a -> Expr
toExpr Opaque a
_ = ConstructorName -> [Expr] -> Expr
App ConstructorName
"Opaque" []