Module

Puregrain.Internal.Util

Package
purescript-puregrain
Repository
roman-mkh/puregrain

Small helpers. Internal: may change without notice.

#safeRange Source

safeRange :: Int -> Int -> Array Int

Like (..), but returns [] when lo > hi instead of PureScript's native descending-range behaviour (1 .. 0 == [1, 0], not [] — unlike Haskell's [1..0] == []). This codebase always wants the Haskell-like "empty when inverted" semantics: every call site builds a range from 1 up to some count that is legitimately allowed to be 0 (e.g. maxDepth), and expects zero elements in that case, not a spurious 2-element descending array.

#isGrid Source

isGrid :: forall a. Int -> Int -> Array (Array a) -> Boolean

Whether the rows form a grid of exactly width × height.

#sizeOf Source

sizeOf :: forall a. Array (Array a) -> String

"width x height", or, for rows of different lengths, how many rows: for a message about a grid of the wrong size.