amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Add type parameter and MonadReader instance to Evaluation for "global settings" #132

Closed recursion-ninja closed 5 years ago

recursion-ninja commented 5 years ago

Currently if we want to represent our "global settings" r in the evaluation monad, we must specify the transformer like so:

EvaluationT (ReaderT r m) a

It would be more ideal to be able to represent the "global settings" in either of the following ways:

Evaluation r a
EvaluationT r m a

This construction provides more flexibly access to the global setting in either the "pure" evaluation context or the "impure" monad transformer context. This construction is likely to also use less memory.

We can then specialize SearchState and similar types to EvaluationT GlobalSettings IO a if we so desire.

recursion-ninja commented 5 years ago

The new EvaluationT r m a has been implemented as a newtyped RWST from transformers, which has had the infamous WriterT "space leak" fixed since version 0.5.6.

See 6b3d04d