commercialhaskell / rio

A standard library for Haskell
Other
838 stars 54 forks source link

Bikeshed: recommending import qualifications for Partial/Unchecked. submodules #171

Closed akhra closed 5 years ago

akhra commented 5 years ago

I've been using a primed version of the root qualifier in my own code, e.g.:

import qualified Data.List.Partial as L'

minimumDef d xs
  | not (null xs) = L'.minimum xs
  | otherwise     = d

I think this fits with the previous decision to use the shortest possible abbreviations (e.g. we decided RIO.ByteString.Lazy would be BL and not B.Lazy). It also sticks out nicely, and despite being legal I don't think I've ever seen a prime in a module name elsewhere.

One concern is that we made the explicit decision to separate Partial (can throw) from Unchecked (can break invariants), and we don't have a second legal symbol to maintain that distinction; RIO.Map.Partial and RIO.Map.Unchecked would both become M'. Personally I'm not concerned with this: I think the important part is being reminded that a function requires care; the details require going to documentation in any case.

snoyberg commented 5 years ago

I'm OK with this move. @lehins you have any thoughts?

lehins commented 5 years ago

I am in favor of this. In fact I've been using tick in my libraries to denote partiality as well. Although I've been using it in function names (eg. index' :: Vector e -> Int -> e vs index :: Vector e -> Int -> Maybe e), but the idea is the same, make partial function stick out.

akhra commented 5 years ago

Addressed by #175.