1-- @inline export overArray arity=1
2module Snapshot.Fusion01 (test) where
6import Data.Array as Array
7import Data.List as List
8import Data.Maybe (Maybe(..))
9import Data.String as String
10import Partial.Unsafe (unsafePartial)
12newtype Fold a = Fold (forall r. (a -> r -> r) -> r -> r)
14mapF :: forall a b. (a -> b) -> Fold a -> Fold b
15mapF f (Fold next) = Fold \cons nil -> next (cons <<< f) nil
17filterMapF :: forall a b. (a -> Maybe b) -> Fold a -> Fold b
18filterMapF f (Fold next) = Fold \cons nil ->
29filterF :: forall a. (a -> Boolean) -> Fold a -> Fold a
30filterF p = filterMapF (\a -> if p a then Just a else Nothing)
32fromArray :: forall a. Array a -> Fold a
33fromArray arr = Fold \cons nil -> do
39 loop (n - 1) $ cons (unsafePartial (Array.unsafeIndex arr n)) acc
40 loop (Array.length arr - 1) nil
42toArray :: forall a. Fold a -> Array a
43toArray (Fold next) = Array.reverse $ List.toUnfoldable $ next List.Cons List.Nil
45overArray :: forall a b. (Fold a -> Fold b) -> Array a -> Array b
46overArray fold = toArray <<< fold <<< fromArray
48test :: Array Int -> Array String
52 >>> filterMapF (String.stripPrefix (String.Pattern "1"))
54 >>> filterF (_ /= "wat")
55 >>> mapF (flip append "1")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list