<commit_before>module Data.CoList

%access public

||| Idris will know that it always can produce a new element in finite time
codata CoList : Type -> Type where
  Nil : CoList a
  (::) : a -> CoList a -> CoList a

infixr 7 ++

||| Append two CoLists
(++) : CoList a -> CoList a -> CoList a
(++) []      right = right
(++) (x::xs) right = x :: (xs ++ right)

instance Semigroup (CoList a) where
  (<+>) = (++)

instance Monoid (CoList a) where
  neutral = []

instance Functor CoList where
  map f []      = []
  map f (x::xs) = f x :: map f xs

instance Show a => Show (CoList a) where
    show xs = "[" ++ show' "" xs ++ "]" where
        show' acc []        = acc
        show' acc [x]       = acc ++ show x
        show' acc (x :: xs) = show' (acc ++ show x ++ ", ") xs

||| Take the first `n` elements of `xs`
|||
||| If there are not enough elements, return the whole coList.
||| @ n how many elements to take
||| @ xs the coList to take them from
takeCo : (n : Nat) -> (xs : CoList a) -> List a
takeCo Z _ = []
takeCo (S n) [] = []<commit_msg>remove fixity redefinition for ++<commit_after>module Data.CoList

%access public

||| Idris will know that it always can produce a new element in finite time
codata CoList : Type -> Type where
  Nil : CoList a
  (::) : a -> CoList a -> CoList a

||| Append two CoLists
(++) : CoList a -> CoList a -> CoList a
(++) []      right = right
(++) (x::xs) right = x :: (xs ++ right)

instance Semigroup (CoList a) where
  (<+>) = (++)

instance Monoid (CoList a) where
  neutral = []

instance Functor CoList where
  map f []      = []
  map f (x::xs) = f x :: map f xs

instance Show a => Show (CoList a) where
    show xs = "[" ++ show' "" xs ++ "]" where
        show' acc []        = acc
        show' acc [x]       = acc ++ show x
        show' acc (x :: xs) = show' (acc ++ show x ++ ", ") xs

||| Take the first `n` elements of `xs`
|||
||| If there are not enough elements, return the whole coList.
||| @ n how many elements to take
||| @ xs the coList to take them from
takeCo : (n : Nat) -> (xs : CoList a) -> List a
takeCo Z _ = []
takeCo (S n) [] = []
{'fraction_non_alphanumeric': 0.16516373991457048, 'fraction_numerical': 0.00047460844803037496, 'mean_word_length': 2.5911413969335606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '95240', 'n_tokens_mistral': 741, 'n_tokens_neox': 717, 'n_words': 296}