From 4426863f07901f626a537f2f0bb717b1bd1b0f6d Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 12 Dec 2023 15:32:47 +0100 Subject: chore: compute patches only when displayed --- app/Render.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/Render.hs') 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' = -- cgit v1.2.3