{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Data.TreeDiff where

import Data.Foldable (Foldable (..))
import Data.Foldable qualified as F
import Data.OMap.Strict
import Data.OSet.Strict
import Test.Cardano.Ledger.Binary.TreeDiff (Expr (..), ToExpr (..))

instance ToExpr a => ToExpr (OSet a) where
  toExpr :: OSet a -> Expr
toExpr OSet a
x = ConstructorName -> [Expr] -> Expr
App ConstructorName
"OSet.fromList" [forall a. ToExpr a => a -> Expr
toExpr forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> [a]
toList OSet a
x]

instance (HasOKey k v, ToExpr v) => ToExpr (OMap k v) where
  listToExpr :: [OMap k v] -> Expr
listToExpr = forall a. ToExpr a => [a] -> Expr
listToExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList
  toExpr :: OMap k v -> Expr
toExpr = forall a. ToExpr a => a -> Expr
toExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList