Skip to content

Instantly share code, notes, and snippets.

@kuribas
Created May 30, 2020 15:38
Show Gist options
  • Select an option

  • Save kuribas/c493c9599d832aac6f68ca9d9d47f376 to your computer and use it in GitHub Desktop.

Select an option

Save kuribas/c493c9599d832aac6f68ca9d9d47f376 to your computer and use it in GitHub Desktop.
Subst in unbound broken
{-# 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
@kuribas

kuribas commented May 30, 2020

Copy link
Copy Markdown
Author

[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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment