Skip to content

Instantly share code, notes, and snippets.

@technic
Created June 28, 2021 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technic/7de9f6589797916a037ac9876d4f567f to your computer and use it in GitHub Desktop.
Save technic/7de9f6589797916a037ac9876d4f567f to your computer and use it in GitHub Desktop.
Demonstration of issue in idris2
module Main
import Data.Vect
||| View for splitting a vector in half, non-recursively
public export
data Split : Vect n a -> Type where
SplitNil : Split []
SplitOne : Split [x]
||| two non-empty parts
SplitPair : {n : Nat} -> {m : Nat} ->
(xs : Vect (S n) a) -> (ys : Vect (S m) a) ->
Split (xs ++ ys)
total
splitHelp : {lz : Nat} -> (head : a) -> (zs : Vect lz a) ->
Nat -> Split (head :: zs)
splitHelp head [] _ = SplitOne
splitHelp head (z :: zs) 0 = SplitPair [head] (z :: zs)
splitHelp head (z :: zs) 1 = SplitPair [head] (z :: zs)
splitHelp head (z :: zs) (S (S k))
= case splitHelp z zs k of
SplitOne => SplitPair [head] (z :: zs)
SplitPair (x :: xs) ys => SplitPair (head :: x :: xs) ys
-- SplitPair Nil _ impossible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment