Haskell Platform proposal: Add the vector package

Roman Leshchinskiy rl at cse.unsw.edu.au
Thu Jul 5 15:20:59 CEST 2012


Simon Marlow wrote:
> On 04/07/2012 16:33, Roman Leshchinskiy wrote:
>> Simon Marlow wrote:
>>> We should be moving towards safe APIs by default, and separating out
>>> unsafe APIs into separate modules.
>>
>> I completely agree with separating out unsafe APIs but I don't
>> understand
>> why modules are the right granularity for this, especially given
>> Haskell's
>> rather rudimentary module system. As I said, the module-based approach
>> results in a significant maintainance burden for vector.
>
> The choice to use the module boundary was made for pragmatic reasons -
> it reduces complexity in the implementation, but also it makes things
> much simpler from the programmer's point of view.  The programmer has a
> clear idea where the boundary lies: in a Safe module, they can only
> import other Safe/Trustworthy modules.  The Safe subset is a collection
> of modules, not some slice of the contents of all modules.  The Haddock
> docs for a module only have to say in one place whether the module is
> considered safe or not.
>
> This is certainly a debatable part of the design, and we went back and
> forth on it once or twice already.  Conceivably it could change in the
> future.  But I don't think this is the right place to discuss the design
> of SafeHaskell, and at least in our experience the current design seems
> to work quite well.

I think we're misunderstanding each other slightly here. You seem to be
using "separating out unsafe APIs" and SafeHaskell as synonyms whereas I'm
only talking about how to do the former in the vector package, not
necessarily using SafeHaskell. So to clarify my position: I'm all for
distinguishing between safe and unsafe APIs and vector already mostly does
that. But I don't want to support SafeHaskell in vector because
SafeHaskell's notion of safety doesn't coincide with the one prevalent in
vector and because SafeHaskell imposes requirements on the module
structure which I consider too heavy-weight for what would only be an
additional and, in this particular library, less useful guarantee.

> Could you say something more about the maintenance burden?  I imagined
> that you would just separate the unsafe (in the SafeHaskell sense)
> operations into separate modules.

At the moment vector has *.Safe modules which reexport the
SafeHaskell-safe functions from other modules. This means that whenever I
add new functions, I have to remember to reexport them from the *.Safe
modules. Adding a new operation to vector already requires touching 4
modules; having to update the *.Safe modules as well is impractical. Which
is why I'd like to drop them.



More information about the Libraries mailing list