diff --git a/servant-server/src/Servant/Server.hs b/servant-server/src/Servant/Server.hs index b5ba471a..74010909 100644 --- a/servant-server/src/Servant/Server.hs +++ b/servant-server/src/Servant/Server.hs @@ -38,7 +38,7 @@ module Servant.Server -- * Config , ConfigEntry(..) , Config(..) - , (.:) + , (.:.) -- * Default error type , ServantErr(..) diff --git a/servant-server/src/Servant/Server/Internal/Config.hs b/servant-server/src/Servant/Server/Internal/Config.hs index 9dc3befa..a5c05d79 100644 --- a/servant-server/src/Servant/Server/Internal/Config.hs +++ b/servant-server/src/Servant/Server/Internal/Config.hs @@ -39,16 +39,16 @@ instance Show (Config '[]) where instance (Show a, Show (Config as)) => Show (Config (ConfigEntry tag a ': as)) where showsPrec outerPrecedence (ConsConfig (ConfigEntry a) as) = showParen (outerPrecedence > 5) $ - shows a . showString " .: " . shows as + shows a . showString " .:. " . shows as instance Eq (Config '[]) where _ == _ = True instance (Eq a, Eq (Config as)) => Eq (Config (a ': as)) where ConsConfig x1 y1 == ConsConfig x2 y2 = x1 == x2 && y1 == y2 -(.:) :: x -> Config xs -> Config (ConfigEntry tag x ': xs) -e .: cfg = ConsConfig (ConfigEntry e) cfg -infixr 5 .: +(.:.) :: x -> Config xs -> Config (ConfigEntry tag x ': xs) +e .:. cfg = ConsConfig (ConfigEntry e) cfg +infixr 5 .:. class HasConfigEntry (cfg :: [*]) (a :: k) (val :: *) | cfg a -> val where getConfigEntry :: proxy a -> Config cfg -> val diff --git a/servant-server/test/Servant/Server/Internal/ConfigSpec.hs b/servant-server/test/Servant/Server/Internal/ConfigSpec.hs index 53436e2e..15cb5bf6 100644 --- a/servant-server/test/Servant/Server/Internal/ConfigSpec.hs +++ b/servant-server/test/Servant/Server/Internal/ConfigSpec.hs @@ -16,8 +16,8 @@ spec = do getConfigEntrySpec :: Spec getConfigEntrySpec = describe "getConfigEntry" $ do - let cfg1 = 0 .: EmptyConfig :: Config '[ConfigEntry "a" Int] - cfg2 = 1 .: cfg1 :: Config '[ConfigEntry "a" Int, ConfigEntry "a" Int] + let cfg1 = 0 .:. EmptyConfig :: Config '[ConfigEntry "a" Int] + cfg2 = 1 .:. cfg1 :: Config '[ConfigEntry "a" Int, ConfigEntry "a" Int] it "gets the config if a matching one exists" $ do @@ -28,20 +28,20 @@ getConfigEntrySpec = describe "getConfigEntry" $ do getConfigEntry (Proxy :: Proxy "a") cfg2 `shouldBe` 1 it "allows to distinguish between different config entries with the same type by tag" $ do - let cfg = 'a' .: 'b' .: EmptyConfig :: Config '[ConfigEntry 1 Char, ConfigEntry 2 Char] + let cfg = 'a' .:. 'b' .:. EmptyConfig :: Config '[ConfigEntry 1 Char, ConfigEntry 2 Char] getConfigEntry (Proxy :: Proxy 1) cfg `shouldBe` 'a' context "Show instance" $ do - let cfg = 1 .: 2 .: EmptyConfig + let cfg = 1 .:. 2 .:. EmptyConfig it "has a Show instance" $ do - show cfg `shouldBe` "1 .: 2 .: EmptyConfig" + show cfg `shouldBe` "1 .:. 2 .:. EmptyConfig" it "bracketing works" $ do - show (Just cfg) `shouldBe` "Just (1 .: 2 .: EmptyConfig)" + show (Just cfg) `shouldBe` "Just (1 .:. 2 .:. EmptyConfig)" it "bracketing works with operators" $ do - let cfg = (1 .: 'a' .: EmptyConfig) :<|> ('b' .: True .: EmptyConfig) - show cfg `shouldBe` "(1 .: 'a' .: EmptyConfig) :<|> ('b' .: True .: EmptyConfig)" + let cfg = (1 .:. 'a' .:. EmptyConfig) :<|> ('b' .:. True .:. EmptyConfig) + show cfg `shouldBe` "(1 .:. 'a' .:. EmptyConfig) :<|> ('b' .:. True .:. EmptyConfig)" it "does not typecheck if key does not exist" $ do