diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

Infinite fails #100

Closed davidweichiang closed 1 year ago

davidweichiang commented 1 year ago

This should have a sum-product of 1:

data Nat = Zero | Succ Nat;

define equal = \m. \n. case m of
  | Zero -> (case n of
    | Zero -> ()
    | Succ n' -> fail)
  | Succ m' -> (case n of
    | Zero -> fail
    | Succ n' -> equal m' n');

define random = amb Zero (Succ random);

equal random Zero

but using perplc -z it hangs.

ccshan commented 1 year ago

Hmm but perplc -c | perplc -z gives [1.0]!

ccshan commented 1 year ago

The automatically generated discard functions for (defunctionalized) Nat, which are unused and infinite, seem to be at fault: If I temporarily change affLinDiscards to return in Transform/Afflin.hs, then perplc -z gives [1.0] as desired.