Haskell Platform proposal: Add the vector package
illissius at gmail.com
Thu Jul 5 17:34:33 CEST 2012
On Thu, Jul 5, 2012 at 4:58 PM, Thomas Schilling
<nominolo at googlemail.com> wrote:
> On 5 July 2012 15:28, Henning Thielemann <lemming at henning-thielemann.de> wrote:
> fe functionality should be the default.
>> I also see a divergence of usages of the term "safe". It is sometimes used
>> where "total (function)" is meant. I prefer the meaning of "safe" in the
>> sense of SafeHaskell and unsafePerformIO.
> Where would you classify functions that don't perform bounds checking?
> They can be used to read (or write!) arbitrary heap locations.
Right. Even if the IO monad can theoretically allow anything, I feel
like there's a qualitative difference between putStrLn and
readIORef/writeIORef on the one hand, and raw pointer arithmetic (and
unchecked array access which is equivalent) on the other, and I
wouldn't mind putting the latter in the Unsafe module together with
the functions which break referential transparency. Even in C some
things are bad times, and you shouldn't be allowed to do those things
in Haskell without having the word "unsafe" somewhere. Perhaps the
distinction I'm looking for is that IO should be allowed to break
referential transparency, but not memory safety? There's a number of
languages which have no concept of referential transparency, but still
don't allow raw pointering (and are quite proud of it).
WRT to Data.Vector.Storable and the Storable class, I wonder if this
isn't analogous to Data.Typeable. Data.Typeable is safe (Trustworthy),
but it depends on Typeable instances being correct, otherwise it can
do any number of bad things. Can we formulate rules which Storable
instances are required to obey, which if they do they are safe? Then
we put the methods of Storable in a separate module which is Unsafe,
which means that any modules declaring instances must also be
Trustworthy (if not Unsafe). Data.Vector.Storable can then also be
Trustworthy, and the property is preserved that if all Trustworthy
things the user trusts are actually safe (which in this case
encompasses following the Storable rules), then unsafe things won't
happen. See also this thread:
Your ship was caught in a monadic eruption.
More information about the Libraries