Return

haskal

1 Name: Anonymous 2018-07-07 22:52
http://hackage.haskell.org/package/primitive-maybe-0.1.0 llol @ haskell

This library provides types for working with arrays of Maybe values. The types in this library can be used as replacements for Array (Maybe a) and SmallArray (Maybe a) that consume less memory and have fewer indirections.

so haskell is so slow that you have to optimize array of maybes. And you can't do that properly you have use a totally new array type. It get sworse:

nothingSurrogate :: Any
nothingSurrogate = error "nothingSurrogate: This value should not be forced!"
{-# NOINLINE nothingSurrogate #-}

unsafeToMaybe :: Any -> Maybe a
unsafeToMaybe a =
case reallyUnsafePtrEquality# a nothingSurrogate of
0# -> Just (unsafeCoerce a)
_ -> Nothing
{-# INLINE unsafeToMaybe #-}

newSmallMaybeArray :: PrimMonad m => Int -> Maybe a -> m (SmallMutableMaybeArray (PrimState m) a)
{-# INLINE newSmallMaybeArray #-}
newSmallMaybeArray i ma = case ma of
Just a -> do
x <- newSmallArray i (unsafeCoerce a)
return (SmallMutableMaybeArray x)
Nothing -> do
x <- newSmallArray i nothingSurrogate
return (SmallMutableMaybeArray x)

unsafeToMaybe :: Any -> Maybe a
unsafeToMaybe a =
case reallyUnsafePtrEquality# a nothingSurrogate of
0# -> Just (unsafeCoerce a)
_ -> Nothing
{-# INLINE unsafeToMaybe #-}

(yes its duplicated)

https://github.com/andrewthad/primitive-maybe/blob/master/src/Data/Primitive/Array/Maybe.hs
https://github.com/andrewthad/primitive-maybe/blob/master/src/Data/Primitive/SmallArray/Maybe.hs

look at the 2 files side by side exact same shit LOL. Fucking beautiful abstraction powers. lambda calculus is amazing.

this language is joke

Return
Name:
Leave this field blank: