lpsmith / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
206 stars 71 forks source link

Applicative instance for Only #270

Open robinp opened 5 years ago

robinp commented 5 years ago

This would be useful to do fmap join . sequenceA . listToMaybe on a query which normally returns [Only (Maybe a)]. With the magic sequence this becomes Only (Maybe a).

robinp commented 5 years ago

Or, to golf more, join . fromOnly . sequenceA . listToMaybe to get Maybe a.

phadej commented 5 years ago

Only is defined in http://hackage.haskell.org/package/Only package