diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-12 15:32:47 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-13 04:47:50 +0100 |
commit | 4426863f07901f626a537f2f0bb717b1bd1b0f6d (patch) | |
tree | 5051a63d4f42d2b219e658803d0c92c5a9d6b693 /app/Render.hs | |
parent | 9516eb2879b47b25e4225fd2b41329e73cada42b (diff) |
chore: compute patches only when displayed
Diffstat (limited to 'app/Render.hs')
-rw-r--r-- | app/Render.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/Render.hs b/app/Render.hs index 964581f..6cb0373 100644 --- a/app/Render.hs +++ b/app/Render.hs @@ -35,6 +35,7 @@ import Data.Text qualified as T import Data.Time.Calendar (Day) import Prettyprinter import Prettyprinter.Render.Terminal +import System.IO.Unsafe (unsafePerformIO) -- | The render class is a superclass of `Pretty`. It exists to facilitate -- reporting styles (see below), as well as decomposing aggregate entities into composable parts (for instance `IssueTitle`, `IssueTags` of `Issue`). @@ -55,6 +56,16 @@ instance Render String instance Render Day where render = render . show +-- TODO Resolve `performUnsafeIO` +-- +-- We want `Renderable a => IO a` in our data structures so that we can defer potentially expensive computation until it is actually required to be rendered. +-- +-- We should be able to eliminate `unsafePerformIO` by lifting `render` to `a -> IO (Doc AnsiStyle)`. +-- +-- @backlog +instance Render a => Render (IO a) where + render = render . unsafePerformIO + -- | The `(<<<)` combinator concatenates renderables. It takes care of inserting spaces between non-empty renderables automatically, obsoleting prettyprinter's `(<+>)` and `(<>)`. (<<<) :: (Render a, Render b) => a -> b -> Doc AnsiStyle (<<<) a' b' = |