import List
-- |@findSublist sub list@ returns the index of the start of the first
-- occurrence of @sub@ inside @list@, or @Nothing@ if there is none.
findSublist :: Eq a => [a] -> [a] -> Maybe Int
findSublist sub list = find (\i -> isPrefixOf sub (drop i list))
(elemIndices (head sub) list)
-- |@findSublists sub list@ returns the indices of the beginnings of all
-- occurrences (including overlapping ones) of @sub@ inside @list@.
findSublists :: Eq a => [a] -> [a] -> [Int]
findSublists sub list = filter (\i -> isPrefixOf sub (drop i list))
(elemIndices (head sub) list)