在agda中已知的模式匹配

luq*_*qui 5 haskell agda

粗略地说,我有

check : UExpr -> Maybe Expr
Run Code Online (Sandbox Code Playgroud)

我有一个测试术语

testTerm : UExpr
Run Code Online (Sandbox Code Playgroud)

我希望能check成功,之后我想提取结果Expr并进一步操纵它.基本上

realTerm : Expr
just realTerm = check testTerm
Run Code Online (Sandbox Code Playgroud)

如果check testTerm结果是这个定义将无法进行类型检查nothing.这可能吗?

pig*_*ker 10

通常的交易是写一些类似的东西

Just : {X : Set} -> Maybe X -> Set
Just (just x) = One -- or whatever you call the fieldless record type
Just nothing = Zero

justify : {X : Set}(m : Maybe X){p : Just m} -> X
justify (just x) = x
justify nothing {()}
Run Code Online (Sandbox Code Playgroud)

如果m计算成功,则p的类型为One,并推断出该值.