úÎ!ÓOC      !"#$%&'()*+,-./0123456789:;<=>?@ABNone"#$/47HVXÿÛ( focuslist'A list with a given element having the .F has some invariants that must be protected. You should not use the  constructor or the  or  accessors. Implemented under the hood as a C. focuslistA  for the .The  is either  (if the  Focuslist is empty), or  D4 to represent focusing on a specific element of the . focuslistA fold function for .This is similar to E for F.9foldFocus "empty" (\i -> "focus at " <> show i) (Focus 3) "focus at 3"foldFocus Nothing Just NoFocusNothing&foldFocus NoFocus Focus focus == focus focuslistA G for focusing on the  constructor in a  data type.  focuslistA G for focusing on the  constructor in a  data type.  focuslistReturns H if a  exists, and I if not.hasFocus (Focus 0)TruehasFocus NoFocusFalse complexity: O(1)  focuslistGet the focus index from a .getFocus (Focus 3)Just 3getFocus NoFocusNothing complexity: O(1)  focuslist Convert a F D to a .maybeToFocus (Just 100) Focus 100maybeToFocus NothingNoFocus  and   witness an isomorphism.&focus == maybeToFocus (getFocus focus),maybeInt == getFocus (maybeToFocus maybeInt) complexity: O(1)  focuslist$Unsafely get the focus index from a .Returns an error if .unsafeGetFocus (Focus 50)50unsafeGetFocus NoFocus*** Exception: ...... complexity: O(1) focuslist is always less than .NoFocus < Focus aThe ordering of : depends on the ordering of the integer contained inside.(a < b) ==> (Focus a < Focus b) focuslistGiven a J for a, generate a valid . focuslistGet the underlying C in a . complexity: O(1) focuslistReturn the length of a .=let Just fl = fromListFL (Focus 2) ["hello", "bye", "parrot"] lengthFL fl3 complexity: O(1) focuslistThis is an invariant that the  must always protect.nThe functions in this module should generally protect this invariant. If they do not, it is generally a bug.The invariants are as follows:The  in a  can never be negative.If there is a $, then it actually exists in the .There needs to be a  if the length of the  is greater than 0. complexity: O(log n), where n is the length of the . focuslistUnsafely create a ¶. This does not check that the focus actually exists in the list. This is an internal function and should generally not be used. It is only safe to use if you ALREADY know the  is within the list."Instead, you should generally use .%The following is an example of using  correctly.!unsafeFromListFL (Focus 1) [0..2]FocusList (Focus 1) [0,1,2]unsafeFromListFL NoFocus []FocusList NoFocus []@ can also be used uncorrectly. The following is an example of  allowing you to create a  that does not pass .#unsafeFromListFL (Focus 100) [0..2]FocusList (Focus 100) [0,1,2]If  returns a K , then  should return the same . complexity: O(n) where n! is the length of the input list. focuslistSafely create a  from a list.)fromListFL (Focus 1) ["cat","dog","goat"]/Just (FocusList (Focus 1) ["cat","dog","goat"])fromListFL NoFocus []Just (FocusList NoFocus [])If the $ is out of range for the list, then L will be returned.,fromListFL (Focus (-1)) ["cat","dog","goat"]Nothing)fromListFL (Focus 3) ["cat","dog","goat"]Nothing'fromListFL NoFocus ["cat","dog","goat"]Nothing complexity: O(n) where n! is the length of the input list.  focuslist Create a  from any M container.This just calls N on the M!, and then passes the result to .ZfromFoldableFL foc (foldable :: Data.Sequence.Seq Int) == fromListFL foc (toList foldable) complexity: O(n) where n is the length of the M! focuslist Create a  with a single element.singletonFL "hello"FocusList (Focus 0) ["hello"] complexity: O(1)" focuslistCreate an empty  without a .emptyFLFocusList NoFocus [] complexity: O(1)# focuslistReturn H if the  is empty.isEmptyFL emptyFLTrueisEmptyFL $ singletonFL "hello"FalseAny  with a  should never be empty.$hasFocusFL fl ==> not (isEmptyFL fl)The opposite is also true. complexity: O(1)$ focuslistAppend a value to the end of a .-This can be thought of as a "snoc" operation.appendFL emptyFL "hello"FocusList (Focus 0) ["hello"]$appendFL (singletonFL "hello") "bye"#FocusList (Focus 0) ["hello","bye"]Appending a value to an empty  is the same as using !.#appendFL emptyFL a == singletonFL a complexity: O(log n) where n is the length of the .% focuslistA combination of $ and 1.;let Just fl = fromListFL (Focus 1) ["hello", "bye", "tree"]appendSetFocusFL fl "pie"0FocusList (Focus 3) ["hello","bye","tree","pie"]The & will always be updated after calling %.2getFocusFL (appendSetFocusFL fl a) > getFocusFL fl complexity: O(log n) where n is the length of the .& focuslistPrepend a value to a .-This can be thought of as a "cons" operation.prependFL "hello" emptyFLFocusList (Focus 0) ["hello"]*The focus will be updated when prepending:%prependFL "bye" (singletonFL "hello")#FocusList (Focus 1) ["bye","hello"]Prepending to a  will always update the :+getFocusFL fl < getFocusFL (prependFL a fl) complexity: O(1)' focuslistUnsafely get the  from a  . If the  is , this function returns O.CThis function is only safe if you already have knowledge that the  has a . Generally, )) should be used instead of this function.)let Just fl = fromListFL (Focus 1) [0..9]unsafeGetFocusFL fl1unsafeGetFocusFL emptyFL*** Exception: ...... complexity: O(1)( focuslistReturn H if the  in a  exists.Return I if the  in a  is . hasFocusFL $ singletonFL "hello"TruehasFocusFL emptyFLFalse complexity: O(1)) focuslistGet the  from a . getFocusFL $ singletonFL "hello"Focus 0)let Just fl = fromListFL (Focus 3) [0..9] getFocusFL flFocus 3getFocusFL emptyFLNoFocus complexity: O(1)* focuslistUnsafely get the value of the  from a  . If the  is , this function returns O.BThis function is only safe if you already have knowledge that the  has a . Generally, +) should be used instead of this function.-let Just fl = fromListFL (Focus 0) ['a'..'c']unsafeGetFocusItemFL fl'a'unsafeGetFocusFL emptyFL*** Exception: ...... complexity: O(log(min(i, n - i))) where i is the , and n is the length of the .+ focuslistGet the item the  is focusing on. Return L if the  is empty.-let Just fl = fromListFL (Focus 0) ['a'..'c']getFocusItemFL flJust 'a'getFocusItemFL emptyFLNothingThis will always return K if there is a .,hasFocusFL fl ==> isJust (getFocusItemFL fl) complexity: O(log(min(i, n - i))) where i is the , and n is the length of the ., focuslist;Lookup the element at the specified index, counting from 0.-let Just fl = fromListFL (Focus 0) ['a'..'c'] lookupFL 0 flJust 'a'Returns L if the index is out of bounds.-let Just fl = fromListFL (Focus 0) ['a'..'c']lookupFL 100 flNothinglookupFL (-1) flNothingAlways returns L if the  is empty.lookupFL i emptyFL == Nothing complexity: O(log(min(i, n - i))) where i' is the index you want to look up, and n is the length of the .- focuslistInsert a new value into the . The ' of the list is changed appropriately.#Inserting an element into an empty  will set the  on that element.insertFL 0 "hello" emptyFLFocusList (Focus 0) ["hello"]The D will not be changed if you insert a new element after the current .&insertFL 1 "hello" (singletonFL "bye")#FocusList (Focus 0) ["bye","hello"]The J will be bumped up by one if you insert a new element before the current .&insertFL 0 "hello" (singletonFL "bye")#FocusList (Focus 1) ["hello","bye"] Behaves like Data.Sequence.PT. If the index is out of bounds, it will be inserted at the nearest available indexinsertFL 100 "hello" emptyFLFocusList (Focus 0) ["hello"](insertFL 100 "bye" (singletonFL "hello")#FocusList (Focus 0) ["hello","bye"])insertFL (-1) "bye" (singletonFL "hello")#FocusList (Focus 1) ["bye","hello"] complexity: O(log(min(i, n - i))) where i) is the index you want to insert at, and n is the length of the .. focuslistRemove an element from a .$If the element to remove is not the , then update the  accordingly.For example, if the c is on index 1, and we have removed index 2, then the focus is not affected, so it is not changed.Glet focusList = unsafeFromListFL (Focus 1) ["cat","goat","dog","hello"]removeFL 2 focusList1Just (FocusList (Focus 1) ["cat","goat","hello"])If the 5 is on index 2 and we have removed index 1, then the 3 will be moved back one element to set to index 1.Glet focusList = unsafeFromListFL (Focus 2) ["cat","goat","dog","hello"]removeFL 1 focusList0Just (FocusList (Focus 1) ["cat","dog","hello"])If we remove the (, then the next item is set to have the .Glet focusList = unsafeFromListFL (Focus 0) ["cat","goat","dog","hello"]removeFL 0 focusList1Just (FocusList (Focus 0) ["goat","dog","hello"])CIf the element to remove is the only element in the list, then the  will be set to .4let focusList = unsafeFromListFL (Focus 0) ["hello"]removeFL 0 focusListJust (FocusList NoFocus [])If the D] for the index to remove is either less than 0 or greater then the length of the list, then L is returned.4let focusList = unsafeFromListFL (Focus 0) ["hello"]removeFL (-1) focusListNothing@let focusList = unsafeFromListFL (Focus 1) ["hello","bye","cat"]removeFL 3 focusListNothingIf the  passed in is Q, then L is returned.removeFL 0 emptyFLNothing complexity: O(log(min(i, n - i))) where i( is index of the element to remove, and n is the length of the ./ focuslist+Find the index of the first element in the .;let Just fl = fromListFL (Focus 1) ["hello", "bye", "tree"]indexOfFL "hello" flJust 0HIf more than one element exists, then return the index of the first one.8let Just fl = fromListFL (Focus 1) ["dog", "cat", "cat"]indexOfFL "cat" flJust 1*If the element doesn't exist, then return L8let Just fl = fromListFL (Focus 1) ["foo", "bar", "baz"]indexOfFL "hogehoge" flNothing0 focuslistDelete an element from a .;let Just fl = fromListFL (Focus 0) ["hello", "bye", "tree"]deleteFL "bye" fl$FocusList (Focus 0) ["hello","tree"]:The focus will be updated if an item before it is deleted.;let Just fl = fromListFL (Focus 1) ["hello", "bye", "tree"]deleteFL "hello" fl"FocusList (Focus 0) ["bye","tree"]/If there are multiple matching elements in the , remove them all.:let Just fl = fromListFL (Focus 0) ["hello", "bye", "bye"]deleteFL "bye" flFocusList (Focus 0) ["hello"]7If there are no matching elements, return the original .;let Just fl = fromListFL (Focus 2) ["hello", "good", "bye"]deleteFL "frog" fl*FocusList (Focus 2) ["hello","good","bye"]1 focuslistSet the  for a .This is just like 2,, but doesn't return the newly focused item.0setFocusFL i fl == fmap snd (updateFocusFL i fl) complexity: O(1)2 focuslist Update the  for a ! and get the new focused element.DupdateFocusFL 1 =<< fromListFL (Focus 2) ["hello","bye","dog","cat"]<Just ("bye",FocusList (Focus 1) ["hello","bye","dog","cat"])If the  is empty, then return L.updateFocusFL 1 emptyFLNothingPIf the new focus is less than 0, or greater than or equal to the length of the , then return L.GupdateFocusFL (-1) =<< fromListFL (Focus 2) ["hello","bye","dog","cat"]NothingDupdateFocusFL 4 =<< fromListFL (Focus 2) ["hello","bye","dog","cat"]Nothing complexity: O(log(min(i, n - i))) where i is the new index to put the  on, and n -- is the length of the .3 focuslistFind a value in a . Similar to  Data.List..;let Just fl = fromListFL (Focus 1) ["hello", "bye", "tree"]findFL (\a -> a == "hello") fl Just "hello"$This will only find the first value.:let Just fl = fromListFL (Focus 0) ["hello", "bye", "bye"]findFL (\a -> a == "bye") fl Just "bye"4If no values match the comparison, this will return L.=let Just fl = fromListFL (Focus 1) ["hello", "bye", "parrot"]findFL (\a -> a == "ball") flNothing complexity: O(n) where n is the length of the .4 focuslistMove an existing item in a  to a new index.The . gets updated appropriately when moving items.=let Just fl = fromListFL (Focus 1) ["hello", "bye", "parrot"]moveFromToFL 0 1 fl3Just (FocusList (Focus 0) ["bye","hello","parrot"])The + may not get updated if it is not involved.=let Just fl = fromListFL (Focus 0) ["hello", "bye", "parrot"]moveFromToFL 1 2 fl3Just (FocusList (Focus 0) ["hello","parrot","bye"])If the element with the  is moved, then the  will be updated appropriately.=let Just fl = fromListFL (Focus 2) ["hello", "bye", "parrot"]moveFromToFL 2 0 fl3Just (FocusList (Focus 0) ["parrot","hello","bye"])5If the index of the item to move is out bounds, then L will be returned.=let Just fl = fromListFL (Focus 2) ["hello", "bye", "parrot"]moveFromToFL 3 0 flNothing(If the new index is out of bounds, then L wil be returned.=let Just fl = fromListFL (Focus 2) ["hello", "bye", "parrot"]moveFromToFL 1 (-1) flNothing complexity: O(log n) where n is the length of the .5 focuslist;Intersperse a new element between existing elements in the .:let Just fl = fromListFL (Focus 0) ["hello", "bye", "cat"]intersperseFL "foo" fl5FocusList (Focus 0) ["hello","foo","bye","foo","cat"]The  is updated accordingly.Blet Just fl = fromListFL (Focus 2) ["hello", "bye", "cat", "goat"]intersperseFL "foo" flBFocusList (Focus 4) ["hello","foo","bye","foo","cat","foo","goat"]The item with the # should never change after calling 5.KgetFocusItemFL (fl :: FocusList Int) == getFocusItemFL (intersperseFL a fl)5! should not have any effect on a  with less than two items."emptyFL == intersperseFL x emptyFL0singletonFL a == intersperseFL x (singletonFL a) complexity: O(n) where n is the length of the .6 focuslist Reverse a . The  is updated accordingly.:let Just fl = fromListFL (Focus 0) ["hello", "bye", "cat"] reverseFL fl)FocusList (Focus 2) ["cat","bye","hello"]Blet Just fl = fromListFL (Focus 2) ["hello", "bye", "cat", "goat"] reverseFL fl0FocusList (Focus 1) ["goat","cat","bye","hello"]The item with the # should never change after calling 5.EgetFocusItemFL (fl :: FocusList Int) == getFocusItemFL (reverseFL fl)+Reversing twice should not change anything.1(fl :: FocusList Int) == reverseFL (reverseFL fl)>Reversing empty lists and single lists should not do anything.emptyFL == reverseFL emptyFL*singletonFL a == reverseFL (singletonFL a) complexity: O(n) where n is the length of the .7 focuslistSort a .The ) will stay with the element that has the .2let Just fl = fromListFL (Focus 2) ["b", "c", "a"]sortByFL compare fl!FocusList (Focus 0) ["a","b","c"]0Nothing will happen if you try to sort an empty , or a  with only one element.#emptyFL == sortByFL compare emptyFL1singletonFL a == sortByFL compare (singletonFL a)The element with the - should be the same before and after sorting.LgetFocusItemFL (fl :: FocusList Int) == getFocusItemFL (sortByFL compare fl) Sorting a  and getting the underlying C/ should be the same as getting the underlying C and then sorting it.OtoSeqFL (sortByFL compare (fl :: FocusList Int)) == sortBy compare (toSeqFL fl)WARNINGV: The computational complexity for this is very bad. It should be able to be done in  O(n * log n)%, but the current implementation is O(n^2) (or worse), where n is the length of the 5. This function could be implemented the same way Data.Sequence.c is implemented. However, a small change needs to be added to that function to keep track of the  in the a and make sure it gets updated properly. If you're interested in fixing this, please send a PR., focuslistIndex to lookup.- focuslist-The index at which to insert the new element. focuslistThe new element.. focuslist(Index of the element to remove from the . focuslistThe  to remove an element from.2 focuslistThe new index to put the  on. focuslist)A tuple of the new element that gets the , and the new .4 focuslistIndex of the item to move. focuslistNew index for the item.7 focuslist(The function to use to compare elements..  !"#$%&'()*+,-./01234567. #+,/3()&$%-.0456127"!'*  R       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOMPQRSTJKUJKVWXYMPZMP[M\]M\^M_`GHaGHbc(focuslist-0.1.0.0-4Vcy87tZ7GfBzvsiVwH5h8Data.FocusList Data.Listfind Data.SequencesortBy FocusListfocusListFocus focusListFocusNoFocus foldFocus_Focus_NoFocushasFocusgetFocus maybeToFocusunsafeGetFocus$fArbitraryFocus$fCoArbitraryFocus $fOrdFocus $fEqFocus$fGenericFocus $fReadFocus $fShowFocus $fEqFocusList$fFunctorFocusList$fGenericFocusList lensFocusListlensFocusListFocus genValidFLtoSeqFLlengthFL invariantFLunsafeFromListFL fromListFLfromFoldableFL singletonFLemptyFL isEmptyFLappendFLappendSetFocusFL prependFLunsafeGetFocusFL hasFocusFL getFocusFLunsafeGetFocusItemFLgetFocusItemFLlookupFLinsertFLremoveFL indexOfFLdeleteFL setFocusFL updateFocusFLfindFL moveFromToFL intersperseFL reverseFLsortByFL$fShowFocusList$fCoArbitraryFocusList$fArbitraryFocusList$fArbitrary1FocusList$fSemiSequenceFocusList$fGrowingAppendFocusList$fMonoTraversableFocusList$fMonoFoldableFocusList$fMonoFunctorFocusList$fTraversableFocusList$fFoldableFocusListcontainers-0.6.0.1Data.Sequence.InternalSeqghc-prim GHC.TypesIntbase Data.Maybemaybe GHC.MaybeMaybe lens-4.17-CT4JBnbANTY4Ofd5JvefG9Control.Lens.TypePrism'TrueFalse*QuickCheck-2.12.6.1-4a6Ozz7bfHzLQyA4XOD1DcTest.QuickCheck.GenGenJustNothing Data.FoldableFoldabletoListGHC.ErrerrorinsertAtEmpty