on master help sign in
Check recursivity of S.
137d2aeMatus Tejiscak
src/IRTS/Compiler.hs+11−1
@@ -529,18 +529,28 @@ getNatLikeCtors ist =
529 $ lookupCtxtExact n
529 $ lookupCtxtExact n
530 $ idris_callgraph ist
530 $ idris_callgraph ist
531
531
532+ isRecursive :: Name -> Name -> Bool
533+ isRecursive tyN cn
534+ | Just (Bind _ Pi{binderTy = P _ argTyN _} _) <- lookupTyExact cn $ tt_ctxt ist
535+ , argTyN == tyN
536+ = True
537+
538+ | otherwise = False
539+
532 natLikeTypes :: [(Name, Name)]
540 natLikeTypes :: [(Name, Name)]
533 natLikeTypes = do
541 natLikeTypes = do
534− (_typeName, TI{con_names}) <- toAlist $ idris_datatypes ist
542+ (typeName, TI{con_names}) <- toAlist $ idris_datatypes ist
535 case con_names of
543 case con_names of
536 [z, s]
544 [z, s]
537 | getUsedCount z == 0
545 | getUsedCount z == 0
538 , getUsedCount s == 1
546 , getUsedCount s == 1
547+ , isRecursive typeName s
539 -> [(z, s)]
548 -> [(z, s)]
540
549
541 [s, z]
550 [s, z]
542 | getUsedCount z == 0
551 | getUsedCount z == 0
543 , getUsedCount s == 1
552 , getUsedCount s == 1
553+ , isRecursive typeName s
544 -> [(z, s)]
554 -> [(z, s)]
545
555
546 _ -> [] -- not a 2-constructor family
556 _ -> [] -- not a 2-constructor family