on master help sign in
Use TupleSections, not list comprehensions
3fec1a0Oleg Grenrus
servant/src/Servant/API/ContentTypes.hs+5−4
@@ -8,6 +8,7 @@
8{-# LANGUAGE OverloadedStrings #-}
8{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE PolyKinds #-}
9{-# LANGUAGE PolyKinds #-}
10{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE ScopedTypeVariables #-}
11+{-# LANGUAGE TupleSections #-}
11{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE UndecidableInstances #-}
14{-# LANGUAGE UndecidableInstances #-}
@@ -243,7 +244,7 @@ class (AllMime list) => AllMimeRender (list :: [*]) a where
243 -> [(M.MediaType, ByteString)] -- content-types/response pairs
244 -> [(M.MediaType, ByteString)] -- content-types/response pairs
244
245
245instance OVERLAPPABLE_ ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
246instance OVERLAPPABLE_ ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
246− allMimeRender _ a = [ (ct, bs) | ct <- NE.toList $ contentTypes pctyp ]
247+ allMimeRender _ a = map (, bs) $ NE.toList $ contentTypes pctyp
247 where
248 where
248 bs = mimeRender pctyp a
249 bs = mimeRender pctyp a
249 pctyp = Proxy :: Proxy ctyp
250 pctyp = Proxy :: Proxy ctyp
@@ -253,7 +254,7 @@ instance OVERLAPPABLE_
253 , AllMimeRender (ctyp' ': ctyps) a
254 , AllMimeRender (ctyp' ': ctyps) a
254 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
255 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
255 allMimeRender _ a =
256 allMimeRender _ a =
256− [ (ct, bs) | ct <- NE.toList $ contentTypes pctyp ]
257+ (map (, bs) $ NE.toList $ contentTypes pctyp)
257 ++ allMimeRender pctyps a
258 ++ allMimeRender pctyps a
258 where
259 where
259 bs = mimeRender pctyp a
260 bs = mimeRender pctyp a
@@ -265,7 +266,7 @@ instance OVERLAPPABLE_
265-- then this would be taken care of. However there is no more specific instance
266-- then this would be taken care of. However there is no more specific instance
266-- between that and 'MimeRender JSON a', so we do this instead
267-- between that and 'MimeRender JSON a', so we do this instead
267instance OVERLAPPING_ ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where
268instance OVERLAPPING_ ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where
268− allMimeRender _ _ = [ (ct, "") | ct <- NE.toList $ contentTypes pctyp ]
269+ allMimeRender _ _ = map (, "") $ NE.toList $ contentTypes pctyp
269 where
270 where
270 pctyp = Proxy :: Proxy ctyp
271 pctyp = Proxy :: Proxy ctyp
271
272
@@ -289,7 +290,7 @@ instance ( MimeUnrender ctyp a
289 , AllMimeUnrender ctyps a
290 , AllMimeUnrender ctyps a
290 ) => AllMimeUnrender (ctyp ': ctyps) a where
291 ) => AllMimeUnrender (ctyp ': ctyps) a where
291 allMimeUnrender _ bs =
292 allMimeUnrender _ bs =
292− [ (ct, x) | ct <- NE.toList $ contentTypes pctyp ]
293+ (map (, x) $ NE.toList $ contentTypes pctyp)
293 ++ allMimeUnrender pctyps bs
294 ++ allMimeUnrender pctyps bs
294 where
295 where
295 x = mimeUnrender pctyp bs
296 x = mimeUnrender pctyp bs