From cfec8ff678b9ff3d28c4923990a21a649bd257ef Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 6 Dec 2022 15:45:05 +0100 Subject: [PATCH] Restore compatibility with lens-aeson <1.2 --- src/haskell/lib/Arion/Services.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/haskell/lib/Arion/Services.hs b/src/haskell/lib/Arion/Services.hs index 249ccf7..8646abb 100644 --- a/src/haskell/lib/Arion/Services.hs +++ b/src/haskell/lib/Arion/Services.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module Arion.Services ( getDefaultExec ) where @@ -9,16 +10,28 @@ import Prelude() import Protolude hiding (to) import qualified Data.Aeson as Aeson +#if MIN_VERSION_lens_aeson(1,2,0) import qualified Data.Aeson.Key as AK +#endif import Arion.Aeson (decodeFile) import Control.Lens import Data.Aeson.Lens +#if MIN_VERSION_lens_aeson(1,2,0) +type Key = AK.Key +mkKey :: Text -> Key +mkKey = AK.fromText +#else +type Key = Text +mkKey :: Text -> Key +mkKey = identity +#endif + -- | Subject to change getDefaultExec :: FilePath -> Text -> IO [Text] getDefaultExec fp service = do v <- decodeFile fp - pure ((v :: Aeson.Value) ^.. key "x-arion" . key "serviceInfo" . key (AK.fromText service) . key "defaultExec" . _Array . traverse . _String) + pure ((v :: Aeson.Value) ^.. key "x-arion" . key "serviceInfo" . key (mkKey service) . key "defaultExec" . _Array . traverse . _String)