Search results

uncons :: forall a. Array a -> Maybe { head :: a, tail :: Array a }

Break an array into its first element and remaining elements.

Using uncons provides a way of writing code that would use cons patterns in Haskell or pre-PureScript 0.7:

f (x : xs) = something
f [] = somethingElse

Becomes:

f arr = case uncons arr of
  Just { head: x, tail: xs } -> something
  Nothing -> somethingElse
P purescript-arrays M Data.Array
uncons :: forall a. NonEmptyArray a -> { head :: a, tail :: Array a }
P purescript-arrays M Data.Array.NonEmpty
uncons :: forall a. List a -> Maybe { head :: a, tail :: List a }

Break a list into its first element, and the remaining elements, or Nothing if the list is empty.

Running time: O(1)

P purescript-lists M Data.List
uncons :: forall a. List a -> Maybe { head :: a, tail :: List a }

Break a list into its first element, and the remaining elements, or Nothing if the list is empty.

Running time: O(1)

P purescript-lists M Data.List.Lazy
uncons :: forall a. NonEmptyList a -> { head :: a, tail :: List a }
P purescript-lists M Data.List.Lazy.NonEmpty
uncons :: forall a. NonEmptyList a -> { head :: a, tail :: List a }
P purescript-lists M Data.List.NonEmpty
uncons :: forall f a. Monad f => ListT f a -> f (Maybe (Tuple a (ListT f a)))

Perform the first step of a computation in the ListT monad.

P purescript-transformers M Control.Monad.List.Trans
uncons :: String -> Maybe { head :: CodePoint, tail :: String }

Returns a record with the first code point and the remaining code points of the string. Returns Nothing if the string is empty. Operates in constant space and time.

>>> uncons "𝐀𝐀 c 𝐀"
Just { head: CodePoint 0x1D400, tail: "𝐀 c 𝐀" }
>>> uncons ""
Nothing
P purescript-strings M Data.String.CodePoints
uncons :: String -> Maybe { head :: Char, tail :: String }

Returns the first character and the rest of the string, if the string is not empty.

uncons "" == Nothing
uncons "Hello World" == Just { head: 'H', tail: "ello World" }
P purescript-strings M Data.String.CodeUnits
uncons :: NonEmptyString -> { head :: CodePoint, tail :: Maybe NonEmptyString }
P purescript-strings M Data.String.NonEmpty.CodePoints
uncons :: NonEmptyString -> { head :: Char, tail :: Maybe NonEmptyString }

Returns the first character and the rest of the string.

uncons "a" == { head: 'a', tail: Nothing }
uncons "Hello World" == { head: 'H', tail: Just (NonEmptyString "ello World") }
P purescript-strings M Data.String.NonEmpty.CodeUnits
uncons :: forall h t s. Cons h t s => Proxy s -> { head :: Proxy h, tail :: Proxy t }
P purescript-typelevel-prelude M Type.Data.Symbol
uncons :: forall a. CatList a -> Maybe (Tuple a (CatList a))

Decompose a catenable list into a Tuple of the first element and the rest of the catenable list.

Running time: O(1)

Note that any single operation may run in O(n).

P purescript-catenable-lists M Data.CatList
uncons :: forall a. CatQueue a -> Maybe (Tuple a (CatQueue a))

Decompose a queue into a Tuple of the first element and the rest of the queue.

Running time: O(1)

Note that any single operation may run in O(n).

P purescript-catenable-lists M Data.CatQueue
uncons :: forall s1 s2 a. Pred s1 s2 => Vec s1 a -> { head :: a, tail :: Vec s2 a }

Get the head and the tail of a non-empty vector.

P purescript-sized-vectors M Data.Vec
uncons :: ByteString -> Maybe { head :: Octet, tail :: ByteString }

Θ(n) Unprepend a byte.

P purescript-bytestrings M Data.ByteString
uncons :: forall a. OSet a -> Maybe { head :: a, tail :: OSet a }
P purescript-ordered-set M Data.Set.Ordered
uncons :: forall a. Seq a -> Maybe (Tuple a (Seq a))

O(1). If the sequence is nonempty, take one element off its left side and return that together with the rest of the original sequence. Otherwise, return Nothing.

P purescript-sequences M Data.Sequence
uncons :: forall a. Seq a -> Tuple a (Seq a)

O(1). Take one element off the left side of a Seq and return it, together with the (possibly empty) remainder of the Seq.

P purescript-sequences M Data.Sequence.NonEmpty
uncons :: Bits -> { head :: Bit, tail :: Bits }
P purescript-binary M Data.Binary.Bits
uncons :: forall t6. List t6 -> (List t6) /\ (Maybe t6)
P purescript-polyform M Polyform.Tokenized
uncons :: forall a. ArrayView a -> Maybe { head :: a, tail :: ArrayView a }

O(1)

P purescript-array-views M Data.ArrayView
uncons :: forall a. NonEmptyArrayView a -> { head :: a, tail :: ArrayView a }
P purescript-array-views M Data.ArrayView.NonEmpty
uncons :: forall a. List a -> { head :: a, tail :: List a }
P purescript-infinite-lists M Data.List.Infinite
uncons :: TokenList -> UnconsToken
P purescript-language-cst-parser M PureScript.CST.Range.TokenList
uncons :: forall a. List a -> Maybe { head :: a, tail :: List a }

Break a list into its first element and remaining elements.

Running time: O(1)

P purescript-rrb-list M RRBList
uncons :: forall a rest r f l. IsSymbol l => Cons l (Proxy2 f) rest r => SProxy l -> Smash r a -> Exists (Uncons f rest a)
P purescript-smash M Data.Smash

The result of extracting a single interpreter from a Smash product.

P purescript-smash M Data.Smash
Uncons :: forall f x r a. (f x) -> (Smash r (x -> a)) -> Uncons f r a x
P purescript-smash M Data.Smash
uncons :: forall a. SortedArray a -> Maybe { head :: a, tail :: SortedArray a }

Deconstructs the array to a head and tail, or returns Nothing if the array is empty.

P purescript-sorted-arrays M Data.SortedArray
P purescript-typelevel-eval M Type.Eval.Row
P purescript-typelevel-eval M Type.Eval.Row
uncons :: forall t a. Unconsable t => t a -> Maybe { head :: a, tail :: t a }
P purescript-unconsable M Data.Unconsable
uncons :: forall b. Ord b => List b -> Maybe { head :: b, tail :: List b }
P purescript-unique-lists M Data.List.Unique
uncons' :: forall r. r -> (SourceToken -> TokenList -> r) -> TokenList -> r
P purescript-language-cst-parser M PureScript.CST.Range.TokenList
uncons1 :: forall s t e. Unconsable1 s t => s e -> { head :: e, tail :: t e }
P purescript-unconsable M Data.Unconsable.NonEmpty
unconsH :: forall a w' w h. Pred w w' => Pos h => Pos w => Matrix h w a -> { head :: Vec h a, tail :: Matrix h w' a }
> unconsH $ matrix22 1 2 3 4
{ head: [1,3], tail: 
  [2]
  [4] }
P purescript-sized-matrices M Data.Matrix.Operations
unconsV :: forall a h' w h. Pred h h' => Pos h => Pos w => Matrix h w a -> { head :: Vec w a, tail :: Matrix h' w a }
> unconsV $ matrix22 1 2 3 4
{ head: [1,2], tail: 
  [3,4] }
P purescript-sized-matrices M Data.Matrix.Operations

Type class for data structures which can be unconsed + some utilities built on top of it

The only requirement for instances of this class is that checkUnconsableLaws must return true for all possible values.

checkUnconsableLaws t =
  unconsableLength t == length t :: Int
P purescript-unconsable M Data.Unconsable
UnconsDone :: UnconsToken
P purescript-language-cst-parser M PureScript.CST.Range.TokenList
UnconsMore :: SourceToken -> TokenList -> UnconsToken
P purescript-language-cst-parser M PureScript.CST.Range.TokenList
unconsPath :: Request -> Tuple (Maybe String) Request

Gets the next segment from the request path if available and returns it along with a scoped request. Useful when routing the request.

P purescript-nodetrout M Nodetrout.Internal.Request

The user should interpret Unconsable1 s t constraint as "s is a non-empty container which can be converted to a possibly empty container t".

P purescript-unconsable M Data.Unconsable.NonEmpty
P purescript-language-cst-parser M PureScript.CST.Range.TokenList
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable.NonEmpty
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable.NonEmpty
unconsableLength :: forall num a t. Unconsable t => Semiring num => t a -> num

Equivalent to length, maybe except of stack safety.

You may want to use this function instead of length if foldr for the particular data type you are using is not stack-safe.

P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable
P purescript-unconsable M Data.Unconsable.NonEmpty
P purescript-unconsable M Data.Unconsable.NonEmpty

No further results.