File: Strict.hs

package info (click to toggle)
haskell-deque 0.4.4.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 128 kB
  • sloc: haskell: 928; makefile: 6
file content (42 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- |
-- Definitions of strict Deque.
--
-- The typical `toList` and `fromList` conversions are provided by means of
-- the `Foldable` and `IsList` instances.
module Deque.Strict
  ( StrictDefs.Deque,
    fromLazy,
    toLazy,
    StrictDefs.fromConsAndSnocLists,
    StrictDefs.cons,
    StrictDefs.snoc,
    StrictDefs.reverse,
    StrictDefs.shiftLeft,
    StrictDefs.shiftRight,
    StrictDefs.filter,
    StrictDefs.take,
    StrictDefs.drop,
    StrictDefs.takeWhile,
    StrictDefs.dropWhile,
    StrictDefs.span,
    StrictDefs.uncons,
    StrictDefs.unsnoc,
    StrictDefs.null,
    StrictDefs.head,
    StrictDefs.last,
    StrictDefs.tail,
    StrictDefs.init,
  )
where

import qualified Deque.Lazy.Defs as LazyDefs
import Deque.Prelude
import qualified Deque.Strict.Defs as StrictDefs

-- | Convert lazy deque to strict deque.
fromLazy :: LazyDefs.Deque a -> StrictDefs.Deque a
fromLazy (LazyDefs.Deque consList snocList) = StrictDefs.Deque (fromList consList) (fromList snocList)

-- | Convert strict deque to lazy deque.
toLazy :: StrictDefs.Deque a -> LazyDefs.Deque a
toLazy (StrictDefs.Deque consList snocList) = LazyDefs.Deque (toList consList) (toList snocList)