Module

Data.ArrayView.Internal

Package
purescript-array-views
Repository
klntsky/purescript-array-views

#singleton Source

singleton :: forall a. a -> ArrayView a

#length Source

length :: forall a. ArrayView a -> Int

#index Source

index :: forall a. ArrayView a -> Int -> Maybe a

#(!!) Source

Operator alias for Data.ArrayView.Internal.index (left-associative / precedence 8)

#concatMap Source

concatMap :: forall b a. (a -> ArrayView b) -> ArrayView a -> ArrayView b

#ArrayToView Source

class ArrayToView a b  where

This typeclass allows to convert any function that operates on Array to a function that operates on ArrayView and vice versa. use only inserts fromArray and toArray in the right places, so don't expect it to increase performance.

Note: either type annotation or partial application of some number of arguments is needed, because otherwise the type inference will not be able to guess the correct type.

import Data.Array as A

-- OK
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith = use (A.zipWith :: (a -> b -> c) -> Array a -> Array b -> Array c)

-- OK
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith f = use (A.zipWith f) -- all three type parameters are tied to `f`

-- Type error
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith = use A.zipWith

Members

Instances

#toArrayView Source