tests pass!
build / build (push) Failing after 1m29s

This commit is contained in:
msyds committed 2026-08-23 00:46:02 -06:00
1 parent bf5595f185
commit 7c0642655f
16 files changed
+211 -720

No files matched your search

+6 -30
View File
@@ -24,12 +24,9 @@ module Gyehoek.Scheme.Syntax
, subst
, getName
, scm
, readExp
, readProgram
, free'
, freeWithBound'
, freeO
, encodeProgram
)
where
@@ -54,7 +51,7 @@ import qualified Effectful.FileSystem.IO.ByteString as FB
import qualified Data.Set.Ordered as O
import Gyehoek.Sexp.Grammar qualified as Sexp
import Gyehoek.Sexp.Grammar qualified as S
import Gyehoek.Sexp.Grammar (DatumIso)
import Gyehoek.Sexp.Grammar (DatumIso, DataIso)
import Gyehoek.Prelude
@@ -125,7 +122,7 @@ data CommandOrDef
deriving stock (Show, Generic, Data)
deriving anyclass (NFData)
data Program = MkProgram
newtype Program = MkProgram
{ commandsAndDefs :: List CommandOrDef
}
deriving stock (Show, Generic, Data)
@@ -221,11 +218,14 @@ instance DatumIso CommandOrDef where
$ S.With (\_Begin -> _Begin . S.beginLike "begin" S.datumIso)
$ S.End
instance DataIso Program where
dataIso = S.dataIso @(List CommandOrDef) >>> S.iso coerce coerce
-- utilities
scm :: QuasiQuoter
scm = GS.makeSx [|| GS.fromSexp @Exp ||]
scm = GS.makeSx [|| S.fromDatumUnsafe S.datumIso ||]
freeWithBound' :: Foldable f => f Name -> Exp -> List Name
freeWithBound' bound = filter (`elem` bound) . free'
@@ -280,27 +280,3 @@ subst f = \e -> cata go e mempty where
go (ExpLetF _ _) _ = error "todo lol"
go (ExpLambdaF bs e) bound = e $ insertFrom bs bound
go e bound = embed $ fmap ($ bound) e
fileName :: FilePath -> FilePath
fileName "-" = "<interactive>"
fileName e = e
hGetContents :: FS.FileSystem :> es => FS.Handle -> Eff es Text
hGetContents h = T.decodeUtf8 <$> FB.hGetContents h
readProgram :: IOE :> es => FilePath -> Eff es Program
readProgram fp = runFileSystem $
FS.withFile fp FS.ReadMode $ \h ->
GS.parseSexps @CommandOrDef (fileName fp) <$> hGetContents h
>>= either error (pure . MkProgram)
readExp :: IOE :> es => FilePath -> Eff es Exp
readExp fp = readProgram fp <&> (^?! #commandsAndDefs . _head . #Command)
encodeProgram :: Program -> Text
encodeProgram p = p.commandsAndDefs
& fmap ((^?! _Right) . GS.encodePretty)
& intersperse "\n\n"
& mconcat