-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move erroring instances of HasClient to separate file
- Loading branch information
Showing
4 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- | Wrapper for Servant.Client.Core.HasClient.Internal, which brings in scope the | ||
-- instance declarations in Servant.Client.Core.HasClient.TypeErrors | ||
module Servant.Client.Core.HasClient | ||
( module Servant.Client.Core.HasClient.Internal | ||
) where | ||
|
||
import Servant.Client.Core.HasClient.Internal | ||
import Servant.Client.Core.HasClient.TypeErrors () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
servant-client-core/src/Servant/Client/Core/HasClient/TypeErrors.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
{-# OPTIONS_GHC -fno-warn-missing-methods #-} | ||
|
||
-- | This module contains erroring instances for @Servant.Client.Core.HasClient.Internal@. | ||
-- They are separated from the bulk of the code, because they raise "missing methods" | ||
-- warnings. These warnings are expected, but ignoring them would lead to missing | ||
-- relevant warnings in @Servant.Client.Core.HasClient.Internal@. Therefore, we put them | ||
-- in a separate file, and ignore the warnings here. | ||
module Servant.Client.Core.HasClient.TypeErrors () | ||
where | ||
|
||
import Prelude () | ||
import Prelude.Compat | ||
|
||
import GHC.TypeLits | ||
(TypeError) | ||
import Servant.API | ||
((:>)) | ||
import Servant.API.TypeErrors | ||
|
||
import Servant.Client.Core.HasClient.Internal | ||
import Servant.Client.Core.RunClient | ||
|
||
-- Erroring instance for HasClient' when a combinator is not fully applied | ||
instance (RunClient m, TypeError (PartialApplication HasClient arr)) => HasClient m ((arr :: a -> b) :> sub) | ||
where | ||
type Client m (arr :> sub) = TypeError (PartialApplication HasClient arr) | ||
clientWithRoute _ _ _ = error "unreachable" | ||
hoistClientMonad _ _ _ _ = error "unreachable" | ||
|
||
-- Erroring instances for 'HasClient' for unknown API combinators | ||
instance {-# OVERLAPPABLE #-} (RunClient m, TypeError (NoInstanceForSub (HasClient m) ty)) => HasClient m (ty :> sub) | ||
|
||
instance {-# OVERLAPPABLE #-} (RunClient m, TypeError (NoInstanceFor (HasClient m api))) => HasClient m api |