Skip to content

Data Constructors in Higher Order Positions #2573

@nikivazou

Description

@nikivazou

Writing (see full example in https://liquidhaskell.goto.ucsd.edu/index.html#?demo=permalink%2F1758872050_934.hs)

{-@ foldCons :: xs:List a -> { foldr Cons Nil xs = xs } @-}

Crashes with

  crash: SMTLIB2 respSat = Error "line 3 column 27651: unknown constant MapFusion.ConsInt declared: (declare-fun MapFusion.Cons (Int (MapFusion.List Int)) (MapFusion.List Int)) "

The reason is that at SMT level (after defunctionalization) foldr expects an "integer" argument and is given the higher order Cons that is not defunctionalized.

Possible solutions:

  1. Enable the {-@ LIQUID "--no-adt" @-} flag that treats data constructors simply as functions (and Cons will get defunctionalized).
  2. Replace Cons in the spec with a function cons that is defined to be equal to Cons.
  3. At serialization replace Cons with a defunctionalized equivalent (I believe such exist already?).
  4. At serialization eta expand?

From the above 1. and 2. just work, while 3 and 4 would require edits in LH.

@AlecsFerra @clayrat @pacastega

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions