Skip to content

Fix strange parsing of BooleanFormula

Consider the following program.

module Foo where

class Meh a where
  foo :: a -> String
  foo1 :: a -> String
  foo2 :: a -> String

  {-# MINIMAL foo, foo1, foo2 #-}

The minimal pragma is parsed quite weirdly.

        (MinimalSig "{-# MINIMAL" 
         (And 
          [
           (Var 
            ({ test.hs:8:15-17 }
             (Unqual {OccName: foo}))),
           (And 
            [
             (Var 
              ({ test.hs:8:20-23 }
               (Unqual {OccName: foo1}))),
             (Var 
              ({ test.hs:8:26-29 }
               (Unqual {OccName: foo2})))])])))] {Bag(Located (HsBind RdrName)):

To be clear, it is parsed as And [foo, And [foo1, foo2]] rather than And [foo, foo1, foo2].

Either the datatype should be change to be more like a binary tree or the parser should be changed to handle this properly. I think the second option would be easiest.

Edited by Matthew Pickering
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information