File: Extended.hs

package info (click to toggle)
patat 0.15.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,196 kB
  • sloc: haskell: 4,120; makefile: 86; xml: 22; sh: 17
file content (16 lines) | stat: -rw-r--r-- 370 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Data.Sequence.Extended
    ( module Data.Sequence
    , cons
    , safeIndex
    ) where

import Data.Sequence

cons :: a -> Seq a -> Seq a
cons x xs = singleton x <> xs

safeIndex :: Seq a -> Int -> Maybe a
safeIndex s n
    | n < 0                       = Nothing
    | n >= Data.Sequence.length s = Nothing
    | otherwise                   = Just $ index s n