{-# OPTIONS_GHC -fplugin=TcYolo #-}
module TcYoloExample
( whereIsYourGodNow
, noneShallPass
, becauseWhyNot
) where
import Control.Monad.IO.Class (MonadIO(liftIO))
import Control.Monad.Trans.Except (Except)
import Control.Monad.Trans.Reader (Reader)
import Control.Monad.Trans.State (StateT, get)
import Data.Functor.Identity (Identity)
import System.IO.Error (userError)
import System.Random (Random(randomIO))
whereIsYourGodNow :: Reader () Int
whereIsYourGodNow = liftIO randomIO
noneShallPass :: Identity ()
noneShallPass = liftIO . ioError . userError $ "blah"
becauseWhyNot :: StateT Int (Except String) Int
becauseWhyNot = do
fileLength <- fmap length (liftIO . readFile $ "some-file.txt")
extraLength <- get
pure $ fileLength + extraLength
-- Note that the above code typechecks, but termination is a different story! 😛
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
GHC type checker plugin to solve MonadIO constraints anywhere they are wanted!
License
jship/tc-yolo
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
GHC type checker plugin to solve MonadIO constraints anywhere they are wanted!
Resources
License
Stars
Watchers
Forks
Releases
No releases published