@@ -1,4 +1,5 @@
11{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveFunctor #-}
23{-# LANGUAGE DeriveGeneric #-}
34{-# LANGUAGE DeriveTraversable #-}
45{-# LANGUAGE FlexibleContexts #-}
@@ -23,7 +24,7 @@ import Data.Map (Map)
2324import qualified Data.Map as Map
2425import Data.Monoid
2526import Data.Scientific (Scientific)
26−import Data.String (fromString)
27+import Data.String (IsString(..))
2728import Data.Text (Text)
2829import qualified Data.Text as Text
2930import GHC.Generics (Generic)
@@ -145,12 +146,18 @@ data License = License
145146 , _licenseUrl :: Maybe URL
146147 } deriving (Eq, Show, Generic, Data, Typeable)
147148
149+instance IsString License where
150+ fromString s = License (fromString s) Nothing
151+
148152-- | The host (name or ip) serving the API. It MAY include a port.
149153data Host = Host
150154 { _hostName :: HostName -- ^ Host name.
151155 , _hostPort :: Maybe PortNumber -- ^ Optional port.
152156 } deriving (Eq, Show, Generic, Typeable)
153157
158+instance IsString Host where
159+ fromString s = Host s Nothing
160+
154161hostConstr :: Constr
155162hostConstr = mkConstr hostDataType "Host" [] Prefix
156163
@@ -582,6 +589,9 @@ data Response = Response
582589 , _responseExamples :: Maybe Example
583590 } deriving (Eq, Show, Generic, Data, Typeable)
584591
592+instance IsString Response where
593+ fromString s = Response (fromString s) Nothing mempty Nothing
594+
585595type HeaderName = Text
586596
587597data Header = Header
@@ -680,6 +690,9 @@ data Tag = Tag
680690 , _tagExternalDocs :: Maybe ExternalDocs
681691 } deriving (Eq, Show, Generic, Data, Typeable)
682692
693+instance IsString Tag where
694+ fromString s = Tag (fromString s) Nothing Nothing
695+
683696-- | Allows referencing an external resource for extended documentation.
684697data ExternalDocs = ExternalDocs
685698 { -- | A short description of the target documentation.
@@ -698,7 +711,10 @@ newtype Reference = Reference { getReference :: Text }
698711data Referenced a
699712 = Ref Reference
700713 | Inline a
701− deriving (Eq, Show, Data, Typeable)
714+ deriving (Eq, Show, Functor, Data, Typeable)
715+
716+instance IsString a => IsString (Referenced a) where
717+ fromString = Inline . fromString
702718
703719newtype URL = URL { getUrl :: Text } deriving (Eq, Show, ToJSON, FromJSON, Data, Typeable)
704720