Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
/ tc-yolo Public archive

GHC type checker plugin to solve MonadIO constraints anywhere they are wanted!

License

Notifications You must be signed in to change notification settings

jship/tc-yolo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synopsis

{-# 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! 😛

About

GHC type checker plugin to solve MonadIO constraints anywhere they are wanted!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages