I thought this thread was worth revisiting You asked
"I'm wondering if exhaustive pattern matching (like in Standard ML) is
featured in Shen."
The answer is 'no'
"So is it possible to have warnings in such cases or exhaustive
pattern matching?".
I said there is no general algorithm for testing exhaustive matching
wrt arbitrary Shen type defs *but* you set up your type definitions in
a case based way to do exhaustive testing for you.
For example, here is such a definition of bit.
Shen 2010, copyright (C) 2010 Mark Tarver
www.shenlanguage.org, version 7
running under Common Lisp, implementation: CLisp
port 1.2 ported by Mark Tarver
(0-) (datatype bit
X : bit; P : A; Q : A;
______________________
(cases (= X 1) P
(= X 0) Q) : A;)
bit
(1-) (tc +)
true
(2+) (define logical-and
{bit --> bit --> boolean}
X Y -> (cases (= X 1) (cases (= Y 1) true
(= Y 0) false)
(= X 0) false))
logical-and : (bit --> (bit --> boolean))
You can check that if you miss a case out in that definition that the
whole thing fails. A few remarks.
1. Cases must not only be exhaustive, but have to be entered in the
same order as in the type def.
2. Exhaustive failure is signalled by a type error message.
3. The system has no idea of what a bit is. To armour the system
against possible non-exhaustive error, you want to avoid defining a
bit as a concrete type and instead have your own bit-entry function
(define bit-entry
-> (let Bit (input)
(cases (= Bit 0) Bit
(= Bit 1) Bit
true (error "~A is not a bit~%" Bit))))
and have the axiom
_________________
(bit-entry) : bit;
Mark