{-# LANGUAGE RankNTypes #-}

module Cardano.Ledger.Binary.FlatTerm (
  C.FlatTerm,
  C.TermToken (..),
  toFlatTerm,
  fromFlatTerm,
  C.validFlatTerm,
)
where

import Cardano.Ledger.Binary.Decoding
import Cardano.Ledger.Binary.Encoding
import qualified Codec.CBOR.FlatTerm as C

toFlatTerm :: Version -> Encoding -> C.FlatTerm
toFlatTerm :: Version -> Encoding -> FlatTerm
toFlatTerm Version
version = Encoding -> FlatTerm
C.toFlatTerm forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> Encoding -> Encoding
toPlainEncoding Version
version

fromFlatTerm :: Version -> (forall s. Decoder s a) -> C.FlatTerm -> Either String a
fromFlatTerm :: forall a.
Version -> (forall s. Decoder s a) -> FlatTerm -> Either String a
fromFlatTerm Version
version forall s. Decoder s a
decoder = forall a. (forall s. Decoder s a) -> FlatTerm -> Either String a
C.fromFlatTerm (forall s a.
Maybe ByteString -> Version -> Decoder s a -> Decoder s a
toPlainDecoder forall a. Monoid a => a
mempty Version
version forall s. Decoder s a
decoder)