@@ -1,5 +1,6 @@
11{-# LANGUAGE CPP #-}
22{-# LANGUAGE DeriveDataTypeable #-}
3+{-# LANGUAGE DeriveFunctor #-}
34{-# LANGUAGE DeriveGeneric #-}
45{-# LANGUAGE DeriveTraversable #-}
56{-# LANGUAGE FlexibleContexts #-}
@@ -28,7 +29,7 @@ import Data.Map (Map)
2829import qualified Data.Map as Map
2930import Data.Monoid
3031import Data.Scientific (Scientific)
31−import Data.String (fromString)
32+import Data.String (IsString(..))
3233import Data.Text (Text)
3334import qualified Data.Text as Text
3435import GHC.Generics (Generic)
@@ -150,12 +151,18 @@ data License = License
150151 , _licenseUrl :: Maybe URL
151152 } deriving (Eq, Show, Generic, Data, Typeable)
152153
154+instance IsString License where
155+ fromString s = License (fromString s) Nothing
156+
153157-- | The host (name or ip) serving the API. It MAY include a port.
154158data Host = Host
155159 { _hostName :: HostName -- ^ Host name.
156160 , _hostPort :: Maybe PortNumber -- ^ Optional port.
157161 } deriving (Eq, Show, Generic, Typeable)
158162
163+instance IsString Host where
164+ fromString s = Host s Nothing
165+
159166hostConstr :: Constr
160167hostConstr = mkConstr hostDataType "Host" [] Prefix
161168
@@ -591,6 +598,9 @@ data Response = Response
591598 , _responseExamples :: Maybe Example
592599 } deriving (Eq, Show, Generic, Data, Typeable)
593600
601+instance IsString Response where
602+ fromString s = Response (fromString s) Nothing mempty Nothing
603+
594604type HeaderName = Text
595605
596606data Header = Header
@@ -689,6 +699,9 @@ data Tag = Tag
689699 , _tagExternalDocs :: Maybe ExternalDocs
690700 } deriving (Eq, Show, Generic, Data, Typeable)
691701
702+instance IsString Tag where
703+ fromString s = Tag (fromString s) Nothing Nothing
704+
692705-- | Allows referencing an external resource for extended documentation.
693706data ExternalDocs = ExternalDocs
694707 { -- | A short description of the target documentation.
@@ -707,7 +720,10 @@ newtype Reference = Reference { getReference :: Text }
707720data Referenced a
708721 = Ref Reference
709722 | Inline a
710− deriving (Eq, Show, Data, Typeable)
723+ deriving (Eq, Show, Functor, Data, Typeable)
724+
725+instance IsString a => IsString (Referenced a) where
726+ fromString = Inline . fromString
711727
712728newtype URL = URL { getUrl :: Text } deriving (Eq, Show, ToJSON, FromJSON, Data, Typeable)
713729