set show timing off .
set show advisories off .

***
***	Test parameterized views.
***

fmod FOO{X :: TRIV, Y :: TRIV} is
  inc MAP{X, Y} + SET{X} .
endfm

view SetAsDefault{X :: TRIV} from DEFAULT to SET*{X} is
  sort Elt to Set{X} .
  op 0 to {} .
endv

fmod ARRAY-OF-SETS{X :: TRIV, Y :: TRIV} is
  inc ARRAY{X, SetAsDefault{Y}} .
endfm

fmod TEST is
  inc ARRAY-OF-SETS{String, Nat} .
endfm

red in TEST : insert("one", {1}, insert("one-two", {1,2}, empty)) .
red in TEST : insert("one", {1}, insert("one-two", {1,2}, empty))["unseen"] .
red in TEST : insert("one", {1}, insert("one-two", {1,2}, empty))["one"] .


fmod TEST2 is
  inc ARRAY{String, SetAsDefault{Nat}} .
endfm

red in TEST2 : insert("one", {1}, insert("one-two", {1,2}, empty)) .
red in TEST2 : insert("one", {1}, insert("one-two", {1,2}, empty))["unseen"] .
red in TEST2 : insert("one", {1}, insert("one-two", {1,2}, empty))["one"] .


view ArrayOfSets{X :: TRIV, Y :: TRIV} from TRIV to ARRAY{X, SetAsDefault{Y}} is
  sort Elt to Array{X,SetAsDefault{Y}} .
endv

fmod LIST-OF-ARRAYS-OF-SETS{X :: TRIV, Y :: TRIV} is
  inc LIST{ArrayOfSets{X, Y}} .
endfm

fmod TEST3 is
  inc LIST-OF-ARRAYS-OF-SETS{String, Nat} .
endfm

red in TEST3 : insert("one", {1}, insert("one-two", {1,2}, empty))
  insert("one", {1}, insert("one-two-three", {1,2,3}, empty))
  insert("two", {2}, insert("one-two-three", {1,2,3}, empty)) .


fmod TEST4 is
  inc ARRAY{String, SetAsDefault{DEFAULT}{Nat0}} .
endfm

red in TEST4 : insert("one", {1}, insert("one-two", {1,2}, empty))["one"] .

show views .
show modules .
