Null Pointer Pattern

Carter Schonwald carter.schonwald at gmail.com
Tue Aug 18 17:18:46 UTC 2020


That’s a really nice idea !

On Tue, Aug 18, 2020 at 2:54 AM Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
>
> On Mon, 17 Aug 2020, Carter Schonwald wrote:
>
>
>
> > There’s an interesting idea or two in here.  Like, should we support
>
> > having non-nullable pointers?
>
>
>
> That was my first idea, too.
>
>
>
> newtype NonNullPtr a = NonNullPtr (Ptr a)
>
>
>
> maybeNonNull :: Ptr a -> Maybe (NonNullPtr a)
>
>
>
> Using NonNullPtr in FFI declarations would make the interfaces safer.
>
>
>
> E.g.
>
>     dst <- mallocArray n
>
>     for (maybeNonNull dst) $ \dstNonNull ->
>
>        copyArray dstNonNull srcNonNull n
>
>
>
> That seems better than testing for nullPtr and then forgeting this
>
> information in the type, again.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200818/a2e162ab/attachment.html>


More information about the Libraries mailing list