Stability | provisional |
---|---|
Maintainer | Hugo Pacheco <hpacheco@nii.ac.jp> |
Safe Haskell | None |
Collection of put-based programming examples
- mapPut :: Eq a => Putlens st e b a -> Putlens st e [b] [a]
- unfoldrPut :: (Eq a, Eq b) => Putlens st e (b, a) a -> a -> Putlens st e [b] a
- unfoldrSPut :: (Eq a, Eq b) => Putlens st e (b, a) a -> a -> Putlens st e [b] a
- nilPut :: Putlens st e [a] ()
- consPut :: Putlens st e [a] (a, [a])
- unnilPut :: Putlens st e () [a]
- unconsPut :: Putlens st e (a, [a]) [a]
- unheadPut :: Eq a => Putlens st e [a] a
- untailPut :: Eq a => Putlens st e [a] [a]
- wrapPut :: Eq a => Putlens st e [a] a
- unwrapPut :: Eq a => Putlens st e a [a]
- data Tree a
- unnodePut :: forall st e a. Putlens st e (a, (Tree a, Tree a)) (Tree a)
- nodePut :: forall st e a. Putlens st e (Tree a) (a, (Tree a, Tree a))
- unemptyPut :: forall st e a. Putlens st e () (Tree a)
- emptyPut :: forall st e a. Putlens st e (Tree a) ()
- catPut :: Eq a => Putlens st e ([a], [a]) [a]
- exCatPut1 :: [Integer]
- exCatPut2 :: ([Integer], [Integer])
- exCatPut3 :: ([Integer], [Integer])
- exCatPut4 :: ([Integer], [Integer])
- catPutN :: Eq a => (Maybe ([a], [a]) -> [a] -> Int) -> Putlens st e ([a], [a]) [a]
- catPutN' :: Eq a => Putlens Int e ([a], [a]) [a]
- catPut2 :: Putlens st e ([Integer], [Integer]) [Integer]
- exCatPut21 :: [Integer]
- exCatPut22 :: ([Integer], [Integer])
- exCatPut23 :: ([Integer], [Integer])
- exCatPut24 :: ([Integer], [Integer])
- catPutP :: Eq a => (e -> a -> Bool) -> Putlens st e ([a], [a]) [a]
- catPutSame :: Eq a => Putlens st e ([a], [a]) [a]
- exCatPutSame1 :: [Integer]
- exCatPutSame2 :: ([Integer], [Integer])
- exCatPutSame3 :: ([Integer], [Integer])
- catPutPred :: Ord a => a -> Putlens st e ([a], [a]) [a]
- exCatPutPred1 :: [Integer]
- exCatPutPred2 :: ([Integer], [Integer])
- exCatPutPred3 :: ([Integer], [Integer])
- exCatPutPred4 :: ([Integer], [Integer])
- succPut :: Putlens st e Int Int
- predPut :: Putlens st e Int Int
- data Nat
- unsuccNPut :: forall st e. Putlens st e Nat Nat
- succNPut :: forall st e. Putlens st e Nat Nat
- unzeroNPut :: forall st e. Putlens st e () Nat
- zeroNPut :: forall st e. Putlens st e Nat ()
- natPut :: Putlens st e Nat Int
- int :: Nat -> Int
- nat :: Int -> Nat
- lengthNatPut :: Eq a => (Int -> a) -> Putlens st e [a] Nat
- exLengthNatPut1 :: Nat
- exLengthNatPut2 :: [Char]
- exLengthNatPut3 :: [Char]
- embedAtPut :: Eq a => Int -> Putlens st e [a] a
- embedAtPut' :: Eq a => Putlens st e (Int, [a]) a
- embedAtPut1 :: Eq a => Int -> Putlens st e [a] a
- embedAtPut1' :: Eq a => Putlens st e (Int, [a]) a
- exEmbedAtPut1 :: Char
- exEmbedAtPut2 :: [Char]
- exEmbedAtPut3 :: [Char]
- exEmbedAtPut4 :: Char
- exEmbedAtPut5 :: [Char]
- embedAtPut2 :: Eq a => Int -> Putlens st e [a] a
- splitAtPut :: Eq a => Putlens st e (Int, [a]) ([a], [a])
- exEmbedAtPut21 :: Char
- exEmbedAtPut22 :: [Char]
- exEmbedAtPut23 :: [Char]
- splitPut :: Integral a => (st -> a -> a -> a) -> Putlens st e (a, a) a
- summandsPut1 :: Integral a => Putlens st e [a] a
- summandsPut2 :: Integral a => Putlens st e [a] a
- summandsPut3 :: Integral a => Putlens st e [a] a
- summandsPut3' :: Integral a => Putlens a e [a] a
- summandsPut4 :: Integral a => Putlens st e [a] a
- summandsPut4' :: Integral a => Putlens a e [a] a
- exSummandsPut1 :: Integer
- exSummandsPut2 :: [Integer]
- exSummandsPut3 :: [Integer]
- exSummandsPut4 :: [Integer]
- exSummandsPut5 :: [Integer]
- exSummandsPut6 :: [Integer]
- exSummandsPut7 :: [Integer]
- replicatePut :: Eq a => Putlens st e (a, Int) [a]
- exReplicatePut1 :: (Char, Int)
- exReplicatePut2 :: (Char, Int)
- replicateListPut :: Eq a => Putlens st e [(a, Int)] [a]
- recoverzerosPut :: Eq a => Putlens st e [(a, Int)] [(a, Int)]
- splitListPut :: Eq a => Putlens st e [[a]] [a]
- exReplicateListPut1 :: [Char]
- exReplicateListPut2 :: [(Char, Int)]
- halvePut :: Eq a => a -> Putlens st e [a] [a]
- exHalvePut1 :: [Char]
- exHalvePut2 :: [Char]
- halvePut2 :: Eq a => a -> Putlens st e [a] [a]
- halvePut2' :: Eq a => a -> Putlens st e ([a], Int) ([a], Int)
- exHalvePut21 :: [Char]
- exHalvePut22 :: [Char]
- exHalvePut23 :: [Char]
- halvePut3 :: Eq a => a -> Putlens st e [a] [a]
- halvePut3' :: Eq a => a -> Putlens Int e ([a], Int) [a]
- exHalvePut31 :: [Char]
- exHalvePut32 :: [Char]
- exHalvePut33 :: [Char]
- isumPut :: Putlens st e [Int] [Int]
- subtractPut :: Int -> Putlens st e Int Int
- exIsumPut1 :: [Int]
- exIsumPut2 :: [Int]
- iunsortPut1 :: Ord a => Putlens st e [a] [a]
- delPut1 :: Ord a => Putlens st e (a, [a]) [a]
- iunsortPut2 :: Ord a => Putlens st e [a] [a]
- delPut2 :: Ord a => Putlens st e (a, [a]) [a]
- exIunsortPut1 :: [Integer]
- exIunsortPut2 :: [Integer]
- exIunsortPut3 :: [Integer]
- qsortPut :: Ord a => Putlens st e [a] [a]
- partitionPut :: Ord a => Putlens st e (a, [a]) (a, ([a], [a]))
- catPutNonEmptyRight :: Eq a => Putlens st e ([a], [a]) [a]
- exQsortPut1 :: [Integer]
- exQsortPut2 :: [Integer]
- exQsortPut3 :: [Integer]
- type Pos = Int
- segments :: [a] -> [[a]]
- mssPut :: Putlens st e [Int] Int
- mssPut' :: Bool -> Putlens st e [Int] Int
- positionsPut :: Eq a => Putlens st e [a] [(Pos, a)]
- positionsPut' :: Eq a => Putlens st [(Pos, a)] (Int, [a]) [(Pos, a)]
- maxSumSegsPut :: Putlens st e (Map Pos Int, [[Pos]]) Int
- maxSumSegsPut' :: Putlens Bool e (Map Int Int, [[Pos]]) Int
- lookupSegPut :: Eq a => Putlens st e (Map Int a, [Int]) [a]
- lookupIntMapPut :: Eq a => Putlens st e (Int, Map Int a) a
- maxPut :: (Num a, Ord a) => Putlens Bool e (a, a) a
- fromListPut :: (Eq a, Ord k) => Putlens st e [(k, a)] (Map k a)
- toListPut :: (Eq a, Ord k) => Putlens st e (Map k a) [(k, a)]
- exMssPut1 :: Int
- exMssPut2 :: [Int]
- exMssPut3 :: [Int]
- exMssPut4 :: [Int]
- exMssPut5 :: [Int]
Lists
Constructor/destructor putlenses for lists
example of automatically deriving constructor/destructor putlenses for binary trees
unemptyPut :: forall st e a. Putlens st e () (Tree a)Source
List concatenation
catPutN :: Eq a => (Maybe ([a], [a]) -> [a] -> Int) -> Putlens st e ([a], [a]) [a]Source
List concatenation (split the view list at position n-1)
catPut2 :: Putlens st e ([Integer], [Integer]) [Integer]Source
List concatenation (split the view list in half)
exCatPut21 :: [Integer]Source
exCatPut22 :: ([Integer], [Integer])Source
exCatPut23 :: ([Integer], [Integer])Source
exCatPut24 :: ([Integer], [Integer])Source
catPutP :: Eq a => (e -> a -> Bool) -> Putlens st e ([a], [a]) [a]Source
List concatenation (puts elements to the left while satisfying a predicate)
catPutSame :: Eq a => Putlens st e ([a], [a]) [a]Source
List concatenation (puts elements to the left while being equal)
exCatPutSame2 :: ([Integer], [Integer])Source
exCatPutSame3 :: ([Integer], [Integer])Source
catPutPred :: Ord a => a -> Putlens st e ([a], [a]) [a]Source
List concatenation (puts elements to the left while smaller than a particular value)
exCatPutPred2 :: ([Integer], [Integer])Source
exCatPutPred3 :: ([Integer], [Integer])Source
exCatPutPred4 :: ([Integer], [Integer])Source
Integers
Naturals
unsuccNPut :: forall st e. Putlens st e Nat NatSource
unzeroNPut :: forall st e. Putlens st e () NatSource
List length
List lookup
embedAtPut :: Eq a => Int -> Putlens st e [a] aSource
Embeds a value at a fixed position in a list
embedAtPut' :: Eq a => Putlens st e (Int, [a]) aSource
embedAtPut1 :: Eq a => Int -> Putlens st e [a] aSource
Embeds a value at a fixed position in a list (supports extending the length original list)
embedAtPut1' :: Eq a => Putlens st e (Int, [a]) aSource
exEmbedAtPut2 :: [Char]Source
exEmbedAtPut3 :: [Char]Source
exEmbedAtPut5 :: [Char]Source
embedAtPut2 :: Eq a => Int -> Putlens st e [a] aSource
Embeds a value at a fixed position in a list (splitAt approach)
splitAtPut :: Eq a => Putlens st e (Int, [a]) ([a], [a])Source
exEmbedAtPut22 :: [Char]Source
exEmbedAtPut23 :: [Char]Source
List summation
splitPut :: Integral a => (st -> a -> a -> a) -> Putlens st e (a, a) aSource
Splits a view number into two summands (by adding an offset to the original first value)
summandsPut1 :: Integral a => Putlens st e [a] aSource
Updates the sum of a list (preserves the original source and appends the difference to the end)
summandsPut2 :: Integral a => Putlens st e [a] aSource
Updates the sum of a list (distributes the difference by dividing it by two at each recursive step) half of the difference is added to the first element of the source, a quarter to the second, and so on until the remainder is 0
summandsPut3 :: Integral a => Putlens st e [a] aSource
Updates the sum of a list (distributes the difference by dividing it by the length of the original list) distributes the difference evenly among original list numbers
summandsPut3' :: Integral a => Putlens a e [a] aSource
summandsPut4 :: Integral a => Putlens st e [a] aSource
Updates the sum of a list (distributes the difference by dividing it by the length of the original list, always preserving the size f the original list even when the view is zero)
summandsPut4' :: Integral a => Putlens a e [a] aSource
Replicate
replicatePut :: Eq a => Putlens st e (a, Int) [a]Source
Replicate
exReplicatePut1 :: (Char, Int)Source
exReplicatePut2 :: (Char, Int)Source
replicateListPut :: Eq a => Putlens st e [(a, Int)] [a]Source
Replicates a list of elements into a sequence of replicated elements
splitListPut :: Eq a => Putlens st e [[a]] [a]Source
exReplicateListPut2 :: [(Char, Int)]Source
Halve
halvePut :: Eq a => a -> Putlens st e [a] [a]Source
Takes the first half of a list (with a default empty element)
exHalvePut1 :: [Char]Source
exHalvePut2 :: [Char]Source
halvePut2 :: Eq a => a -> Putlens st e [a] [a]Source
Takes the first half of a list (using an increasing counter with each consumed element in the forward direction)
exHalvePut21 :: [Char]Source
exHalvePut22 :: [Char]Source
exHalvePut23 :: [Char]Source
halvePut3 :: Eq a => a -> Putlens st e [a] [a]Source
Takes the first half of a list (using a decreasing counter with the size of the input list, decreased 2 by 2, in the forward direction)
exHalvePut31 :: [Char]Source
exHalvePut32 :: [Char]Source
exHalvePut33 :: [Char]Source
exIsumPut1 :: [Int]Source
exIsumPut2 :: [Int]Source
Sorting
iunsortPut1 :: Ord a => Putlens st e [a] [a]Source
Insertion sort (put according to the original relative source order)
iunsortPut2 :: Ord a => Putlens st e [a] [a]Source
Insertion sort (identity backward transformation)
qsortPut :: Ord a => Putlens st e [a] [a]Source
Quicksort (put according to the original relative source order)
partitionPut :: Ord a => Putlens st e (a, [a]) (a, ([a], [a]))Source
Partition a list into smaller and bigger elements than a given element
catPutNonEmptyRight :: Eq a => Putlens st e ([a], [a]) [a]Source
exQsortPut1 :: [Integer]Source
exQsortPut2 :: [Integer]Source
exQsortPut3 :: [Integer]Source
Maximum segment sum
mssPut :: Putlens st e [Int] IntSource
Updating maximum segment sum when the sum increases, update only the largest segment when the sum decreases, update all segments that surpass the new maximum, from smallest to largest
positionsPut :: Eq a => Putlens st e [a] [(Pos, a)]Source