25 | %hide Data.Vect.fromList
26 | %hide Prelude.toList
53 | ||| This is a concrete instance for Naperian containers
54 | ||| It applies also to `s=Fin n` which is covered by Vect
55 | ||| We therefore want this to only be applied if Vect isn't
56 | %defaulthint
80 | ||| For recursive types we need to extract out the conversion functions
110 | -- public export
111 | -- test : {n : Nat} -> IsConcrete (Vect n)
112 | -- test = MkIsConcrete
113 | -- (Vect n)
114 | -- (%search)
115 | -- (fromVect)
116 | -- (toVect)
235 | ||| Requires making a choice of traversal order
236 | ||| Is there a good reason to prefer a particular order?
249 | -- old
250 | -- ||| Indexing an element of `xs` and then applying `f` to it is the same as
251 | -- ||| mapping `f` over xs, and then indexing the result
252 | -- public export
253 | -- mapIndexPreserve : {0 f : a -> b} ->
254 | -- (xs : List a) ->
255 | -- (i : Fin (length (f <$> xs))) ->
256 | -- f (index' xs (rewrite sym (lengthMap {f=f} xs) in i))
257 | -- = index' (f <$> xs) i
258 | -- mapIndexPreserve (x :: xs) FZ = Refl
259 | -- mapIndexPreserve (x :: xs) (FS j) = mapIndexPreserve xs j
262 | -- the idea is that the bottom part of this file will slowly be made obsolete
263 | -- as more and more things are implemented in terms of containers
266 | ||| Any finite container (i.e. whose each set of positions is finite) can be
267 | ||| given an algebra instance simply by summing up all the concrete values
282 | -- public export
283 | -- {n : Nat} -> Show x => Show (Vect' n x) where
284 | -- show v = show (toVect v)
294 | -- Applicative and Naperian instance follow because the set of shapes is ()
296 | -- analogus to Misc.takeFin, but for Vect'
308 | {---
309 | Ideally, all instances would be defined in terms of ConcreteTypes,
310 | but there are totality checking issues with types whose size isn't known
311 | at compile time
312 | ---}
314 | ||| Is there a different way to convince Idris' totality checker?
319 | -- ||| Is there a different way to convince Idris' totality checker?
320 | -- public export
321 | -- Show a => Show (List' a) where
322 | -- show x = assert_total (show (toList x))
329 | -- some attempts at fixing partiality below
330 | -- public export
331 | -- showListHelper : Show a => List' a -> String
332 | -- showListHelper (0 <| _) = ""
333 | -- showListHelper (1 <| index) = show $ index FZ
334 | -- showListHelper ((S k) <| index)
335 | -- = let (s, rest) = headTail index
336 | -- in show s ++ ", " ++ showListHelper (k <| rest)
338 | -- public export
339 | -- showListHelper : Show a => List' a -> String
340 | -- showListHelper x = show (toList x)
344 | ||| Is there a different way to convince Idris' totality checker?
349 | -- ||| Is there a different way to convince Idris' totality checker?
350 | -- public export
351 | -- Show a => Show (BinTree' a) where
352 | -- show = assert_total (show . toBinTreeSame)
354 | ||| Summing up nodes and leaves of the tree given by the Num a structure
359 | -- public export
360 | -- binTreePosInterface : InterfaceOnPositions BinTree DecEq
361 | -- binTreePosInterface = MkI
365 | ||| Is there a different way to convince Idris' totality checker?
370 | -- ||| Is there a different way to convince Idris' totality checker?
371 | -- public export
372 | -- Show a => Show (BinTreeLeaf' a) where
373 | -- show = assert_total (show . toBinTreeLeaf)
375 | ||| Summing up leaves of the tree given by the Num a structure
382 | ||| Is there a different way to convince Idris' totality checker?
387 | -- ||| Is there a different way to convince Idris' totality checker?
388 | -- public export
389 | -- Show a => Show (BinTreeNode' a) where
390 | -- show = assert_total (show . toBinTreeNode)
392 | ||| Summing up nodes of the tree given by the Num a structure