Skip to content

Add 'etaReaderT' function #233

@chshersh

Description

@chshersh

This function is introduced in the following blog post and helps with optimizing Haskell code:

It has the following defintion:

etaReaderT :: ReaderT r m a -> ReaderT r m a
etaReaderT = ReaderT . oneShot . runReaderT

It can be used if the code like on the snippet below is called in a loop multiple times:

step :: Instr -> ReaderT Config IO Result
step e = case e of
    Add -> do stuff 
    Del -> do stuff 

You just do:

step :: Instr -> ReaderT Config IO Result
step e = etaReaderT $ case e of
    Add ->  do stuff 
    Del ->  do stuff 

Metadata

Metadata

Assignees

Labels

newBring something new into library (add function or type or interface)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions