@@ -22,6 +22,7 @@ module Gyehoek.Scheme.Syntax
|
||||
, free
|
||||
, subst
|
||||
, getName
|
||||
, scm
|
||||
)
|
||||
where
|
||||
|
||||
@@ -47,6 +48,7 @@ import Data.Functor.Foldable hiding (fold)
|
||||
import Data.HashSet (HashSet)
|
||||
import qualified Data.HashSet as HS
|
||||
import Data.Foldable (fold)
|
||||
import Language.Haskell.TH.Quote (QuasiQuoter)
|
||||
|
||||
|
||||
newtype Name = MkName { inner :: Text }
|
||||
@@ -70,7 +72,7 @@ data Prim e
|
||||
| PrimWrite e
|
||||
| PrimZeroP e
|
||||
| PrimNewline
|
||||
deriving (Show, Generic, Functor, Foldable, Traversable, Data)
|
||||
deriving (Show, Generic, Functor, Foldable, Traversable, Data, Eq)
|
||||
|
||||
instance Each (Prim e) (Prim e') e e'
|
||||
|
||||
@@ -80,7 +82,7 @@ data Lit
|
||||
| LitBool Bool
|
||||
| LitString Text
|
||||
| LitQuote Sexp
|
||||
deriving (Show, Generic, Data)
|
||||
deriving (Show, Generic, Data, Eq)
|
||||
|
||||
pattern Void :: Lit
|
||||
pattern Void = LitNil
|
||||
@@ -105,7 +107,7 @@ data Sexp
|
||||
= SexpCons Sexp Sexp
|
||||
| SexpSymbol Text
|
||||
| SexpLit Lit
|
||||
deriving (Show, Generic, Data)
|
||||
deriving (Show, Generic, Data, Eq)
|
||||
|
||||
data CommandOrDef
|
||||
= Command Exp
|
||||
@@ -228,6 +230,9 @@ instance SexpIso CommandOrDef where
|
||||
|
||||
-- utilities
|
||||
|
||||
scm :: QuasiQuoter
|
||||
scm = Gyehoek.Sexp.makeSx [|| Gyehoek.Sexp.fromSexp @Exp ||]
|
||||
|
||||
free :: Exp -> HashSet Name
|
||||
free = cata \case
|
||||
ExpVarF x -> HS.singleton x
|
||||
|
||||
Reference in New Issue
Block a user