Skip to content

Commit f771f78

Browse files
committed
WHY WHY WHY do Pulse functions with functional types no longer typecheck?
This commit gives one example of cumbersome workaround, which I have by far not replicated yet.
1 parent 679a11e commit f771f78

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/lowparse/pulse/LowParse.Pulse.Combinators.fst

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,9 @@ let leaf_compute_remaining_size_dtuple2
19391939
(leaf_compute_remaining_size_dtuple2_body w2)
19401940
)
19411941

1942+
// FIXME: WHY WHY WHY do my Pulse functions with functional types no longer typecheck? WHY WHY WHY do I need to expand the definition of the functional type in Pulse as below? In most cases this will be awfully painful!
19421943
inline_for_extraction
1943-
fn zero_copy_parse_dtuple2
1944+
fn zero_copy_parse_dtuple2'
19441945
(#tl1 #tl2 #th1: Type)
19451946
(#th2: th1 -> Type)
19461947
(#vmatch1: tl1 -> th1 -> slprop)
@@ -1955,10 +1956,17 @@ fn zero_copy_parse_dtuple2
19551956
(#p2: (x: th1) -> parser k2 (th2 x))
19561957
(#s2: (x: th1) -> serializer (p2 x))
19571958
(w2: (xh: Ghost.erased th1) -> zero_copy_parse (vmatch2 xh) (s2 xh))
1958-
: zero_copy_parse #(tl1 `cpair` tl2) #(dtuple2 th1 th2) (vmatch_dep_prod vmatch1 vmatch2) #(and_then_kind k1 k2) #(parse_dtuple2 p1 p2) (serialize_dtuple2 s1 s2)
1959-
= (input: _)
1960-
(#pm: _)
1961-
(#v: _)
1959+
(input: slice byte)
1960+
(#pm: perm)
1961+
(#v: Ghost.erased (dtuple2 th1 th2))
1962+
requires
1963+
pts_to_serialized (serialize_dtuple2 s1 s2) input #pm v
1964+
returns res: (tl1 `cpair` tl2)
1965+
ensures
1966+
vmatch_dep_prod vmatch1 vmatch2 res v **
1967+
Trade.trade
1968+
(vmatch_dep_prod vmatch1 vmatch2 res v)
1969+
(pts_to_serialized (serialize_dtuple2 s1 s2) input #pm v)
19621970
{
19631971
let (input1, input2) = split_dtuple2 s1 j1 s2 input;
19641972
unfold (split_dtuple2_post s1 s2 input pm v (input1, input2));
@@ -1976,6 +1984,25 @@ fn zero_copy_parse_dtuple2
19761984
res
19771985
}
19781986

1987+
inline_for_extraction
1988+
let zero_copy_parse_dtuple2
1989+
(#tl1 #tl2 #th1: Type)
1990+
(#th2: th1 -> Type)
1991+
(#vmatch1: tl1 -> th1 -> slprop)
1992+
(#k1: Ghost.erased parser_kind)
1993+
(#p1: parser k1 th1)
1994+
(#s1: serializer p1)
1995+
(j1: jumper p1)
1996+
(w1: zero_copy_parse vmatch1 s1)
1997+
(sq: squash (k1.parser_kind_subkind == Some ParserStrong))
1998+
(#vmatch2: (x: th1) -> tl2 -> th2 x -> slprop)
1999+
(#k2: Ghost.erased parser_kind)
2000+
(#p2: (x: th1) -> parser k2 (th2 x))
2001+
(#s2: (x: th1) -> serializer (p2 x))
2002+
(w2: (xh: Ghost.erased th1) -> zero_copy_parse (vmatch2 xh) (s2 xh))
2003+
: zero_copy_parse #(tl1 `cpair` tl2) #(dtuple2 th1 th2) (vmatch_dep_prod vmatch1 vmatch2) #(and_then_kind k1 k2) #(parse_dtuple2 p1 p2) (serialize_dtuple2 s1 s2)
2004+
= zero_copy_parse_dtuple2' j1 w1 sq w2
2005+
19792006
inline_for_extraction
19802007
fn read_and_zero_copy_parse_dtuple2
19812008
(#tl #th1: Type)

0 commit comments

Comments
 (0)