Created
May 30, 2020 15:38
-
-
Save kuribas/c493c9599d832aac6f68ca9d9d47f376 to your computer and use it in GitHub Desktop.
Subst in unbound broken
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| module Test where | |
| import GHC.Generics | |
| import Unbound.Generics.LocallyNameless | |
| type Var = Name Factor | |
| data Expr = SumOf [Summand] | |
| deriving (Show, Generic) | |
| data Summand = ProductOf [Factor] | |
| deriving (Show, Generic) | |
| instance Subst Var Expr | |
| instance Subst Var Summand | |
| data Factor = V Var | |
| | C Int | |
| | Subexpr Expr | |
| deriving (Show, Generic) | |
| instance Subst Var Factor where | |
| isvar (V v) = Just (SubstName v) | |
| isvar _ = Nothing |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[1 of 1] Compiling Test ( test.hs, test.o )
test.hs:27:23: error:
• Couldn't match type ‘Factor’ with ‘Name Factor’
arising from a use of ‘SubstName’
• In the first argument of ‘Just’, namely ‘(SubstName v)’
In the expression: Just (SubstName v)
In an equation for ‘isvar’: isvar (V v) = Just (SubstName v)
|
27 | isvar (V v) = Just (SubstName v)