From f9c6c105a2d1f0c967f4acf7227f90338da97732 Mon Sep 17 00:00:00 2001 From: Daniel Firth Date: Sat, 14 Aug 2021 18:14:43 +0000 Subject: [PATCH] Add FromDhall instance for Contravariant functors: Predicate, Equivalence, Op --- dhall/src/Dhall/Marshal/Decode.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dhall/src/Dhall/Marshal/Decode.hs b/dhall/src/Dhall/Marshal/Decode.hs index 9b863479e..6bbdffc9a 100644 --- a/dhall/src/Dhall/Marshal/Decode.hs +++ b/dhall/src/Dhall/Marshal/Decode.hs @@ -2,6 +2,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} @@ -12,6 +13,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} @@ -130,6 +132,7 @@ import Data.Either.Validation , eitherToValidation , validationToEither ) +import Data.Functor.Contravariant (Op(..), Predicate(..), Equivalence(..)) import Data.Hashable (Hashable) import Data.Int (Int16, Int32, Int64, Int8) import Data.List.NonEmpty (NonEmpty (..)) @@ -338,6 +341,12 @@ instance FromDhall (f (Result f)) => FromDhall (Result f) where expected = pure "result" +deriving newtype instance (ToDhall x) => FromDhall (Predicate x) + +deriving newtype instance (ToDhall x) => FromDhall (Equivalence x) + +deriving newtype instance (FromDhall b, ToDhall x) => FromDhall (Op b x) + -- | You can use this instance to marshal recursive types from Dhall to Haskell. -- -- Here is an example use of this instance: