Haskell interpretation of names produces error?

data Prop = Const Bool | Var Char | Not Prop | And Prop Prop | If Prop Prop | Or Prop Prop | Yff Prop Prop -- Why do I get errors if "Yff" is replaced with "Iff"? | Xor Prop Prop type Assoc k v = [(k, v)] -- Hutton, Graham. Programming in Haskell (p. 93). Cambridge University Press. Kindle Edition. find :: Eq k => k -> Assoc k v -> v find k t = head [v | (k', v) <- t, k == k'] -- Hutton, Graham. Programming in Haskell (p. 93). Cambridge University Press. Kindle Edition. type Subst = Assoc Char Bool -- Hutton, 2016, Ch 8.6 eval :: Subst -> Prop -> Bool eval _ (Const b) = b eval s (Var x) = find x s eval s (Not p) = not (eval s p) eval s (And p q) = eval s p && eval s q eval s (If p q) = eval s p <= eval s q eval s (Or p q) = eval s p || eval s q eval s (Yff p q) = eval s p == eval s q -- Iff produces error here eval s (Xor p q) = eval s p /= eval s q -- Hutton 2016 Ch 8.6 vars :: Prop -> [Char] vars (Const _) = [] vars (Var x) = [x] vars (Not p) = vars p vars (And p q) = vars p ++ vars q vars (If p q) = vars p ++ vars q vars (Or p q) = vars p ++ vars q vars (Yff p q) = vars p ++ vars q -- Iff produces error here vars (Xor p q) = vars p ++ vars q -- Hutton 2016 Ch 8.6

Hello trent, On Fri, Sep 21, 2018 at 03:26:02AM -0700, trent shipley wrote:
data Prop = Const Bool [...]
changing all the three occurrences of Yff to Iff does not produce error. If you change only two you will get an error, because you have a pattern-matching against a non-existent constructor -F
participants (2)
-
Francesco Ariis
-
trent shipley