Skip to content

Instantly share code, notes, and snippets.

@ctford
Created October 22, 2017 21:46
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 ctford/aff4e0992e184c7d9ed19f5258a1752c to your computer and use it in GitHub Desktop.
Save ctford/aff4e0992e184c7d9ed19f5258a1752c to your computer and use it in GitHub Desktop.
The totality checker thinks `dual` the last case of makes it partial - even though I would have thought the pattern matching shrinks the argument.
%default total
data Channel : (result :Type ) -> Type
where
Send : a -> Channel a
Receive : a -> Channel a
Finished : Channel ()
(>>=) : Channel a -> ((x:a) -> Channel b) -> Channel b
dual : Channel a -> Channel a
dual (Send x) = (Receive x)
dual (Receive x) = (Send x)
dual Finished = Finished
dual (x >>= f) = (dual x) >>= (dual . f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment