Skip to content

Instantly share code, notes, and snippets.

@ymdfield
Created May 28, 2025 13:49
Show Gist options
  • Select an option

  • Save ymdfield/ffb7038dfd6d755fa6dc2eebcc30edbb to your computer and use it in GitHub Desktop.

Select an option

Save ymdfield/ffb7038dfd6d755fa6dc2eebcc30edbb to your computer and use it in GitHub Desktop.
#!/usr/bin/env -S cabal run -v1
{- cabal:
build-depends: base, heftia-effects ^>= 0.7
ghc-options: -Wall
-}
{-# LANGUAGE GHC2021 #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Monad.Hefty
import Control.Monad.Hefty.NonDet
import Control.Monad.Hefty.State
testProgram :: (State String :> es, Choose :> es) => Eff es Int
testProgram = do
() <- pure () `branch` pure ()
s <- get
put "modified"
pure $ length s
main :: IO ()
main = runEff do
_ <- runNonDet @[] do
x <- runState "unmodified" testProgram
liftIO $ print x
pure ()
-- > main
-- ("modified",10)
-- ("modified",10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment