@@ -122,6 +122,34 @@ type family Elem (a :: *) (ls::[*]) :: Constraint where
122122 Elem a (a ': list) = ()
123123 Elem a (b ': list) = Elem a list
124124
125+-- | 'HasForeignType' maps Haskell types with types in the target
126+-- language of your backend. For example, let's say you're
127+-- implementing a backend to some language __X__:
128+--
129+-- > -- First you need to create a dummy type to parametrize your
130+-- > -- instances.
131+-- > data LangX
132+-- >
133+-- > -- If the language __X__ is dynamically typed then you only need
134+-- > -- a catch all instance of a form
135+-- > instance HasForeignType LangX a where
136+-- > typeFor _ _ = empty
137+-- >
138+-- > -- Otherwise you define instances for the types you need
139+-- > instance HasForeignType LangX Int where
140+-- > typeFor _ _ = "intX"
141+-- >
142+-- > -- Or for example in case of lists
143+-- > instance HasForeignType LangX a => HasForeignType LangX [a] where
144+-- > typeFor lang _ = "listX of " <> typeFor lang (Proxy :: Proxy a)
145+--
146+-- Finally to generate list of information about all the endpoints for
147+-- an API you create a function of a form:
148+--
149+-- > getEndpoints :: (HasForeign LangX api, GenerateList (Foreign api))
150+-- > => Proxy api -> [Req]
151+-- > getEndpoints api = listFromAPI (Proxy :: Proxy LangX) api
152+--
125153class HasForeignType lang a where
126154 typeFor :: Proxy lang -> Proxy a -> ForeignType
127155