hyper 0.1.0.3 → 0.2.1.0
raw patch · 3 files changed
+32/−18 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
- Hyper.Internal: instance Hyper.Internal.Display a => Hyper.Internal.DisplayIO (GHC.Types.IO a)
- Hyper.Internal: instance Hyper.Internal.Display a => Hyper.Internal.DisplayIO a
+ Hyper: addFinalizerSession :: IO () -> IO ()
+ Hyper.Internal: addFinalizerSession :: IO () -> IO ()
+ Hyper.Internal: finalizeSession :: IO ()
+ Hyper.Internal: instance Hyper.Internal.Display a => Hyper.Internal.Display (GHC.Types.IO a)
- Hyper: displayIO :: DisplayIO a => a -> IO Graphic
+ Hyper: displayIO :: Display a => a -> IO Graphic
- Hyper.Internal: displayIO :: DisplayIO a => a -> IO Graphic
+ Hyper.Internal: displayIO :: Display a => a -> IO Graphic
Files
- hyper.cabal +5/−4
- src/Hyper.hs +1/−1
- src/Hyper/Internal.hs +26/−13
hyper.cabal view
@@ -1,5 +1,5 @@ Name: hyper-Version: 0.1.0.3+Version: 0.2.1.0 Synopsis: Display class for the HyperHaskell graphical Haskell interpreter Description: This package is part of the /HyperHaskell/ project and provides@@ -11,9 +11,9 @@ License-file: LICENSE Author: Heinrich Apfelmus Maintainer: Heinrich Apfelmus <apfelmus quantentunnel de>-Copyright: (c) Heinrich Apfelmus 2016-2018+Copyright: (c) Heinrich Apfelmus 2016-2020 -Cabal-version: >= 1.8+Cabal-version: >= 1.10 Build-type: Simple Source-repository head@@ -23,9 +23,10 @@ Library hs-source-dirs: src- build-depends: base >= 4.6 && < 4.13+ build-depends: base >= 4.5 && < 4.15 , deepseq >= 1.2 && < 1.5 , blaze-html >= 0.7 && < 0.10 , text >= 0.11 && < 1.3 exposed-modules: Hyper , Hyper.Internal+ default-language: Haskell2010
src/Hyper.hs view
@@ -10,7 +10,7 @@ Display(..), -- * Internal- displayIO,+ displayIO, addFinalizerSession, ) where import Hyper.Internal
src/Hyper/Internal.hs view
@@ -8,16 +8,19 @@ -- * Documentation Graphic(..), string, html, Display(..),- displayIO,+ finalizeSession, addFinalizerSession, ) where import Control.DeepSeq+import Data.IORef import Data.List (isPrefixOf) import Data.Typeable+import System.IO.Unsafe (unsafePerformIO) -import qualified Data.Text as T-import qualified Data.Text.Lazy as TL-import qualified Text.Blaze.Html as H+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL+import qualified Text.Blaze.Html as H+import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html.Renderer.Text as H {-----------------------------------------------------------------------------@@ -30,7 +33,7 @@ -- | Render a 'String' as a 'Graphic'. string :: String -> Graphic-string = Graphic . TL.toStrict . H.renderHtml . H.toHtml+string = Graphic . TL.toStrict . H.renderHtml . H.div . H.toHtml -- | Render arbitrary HTML code as a 'Graphic'. -- @@ -46,8 +49,11 @@ ------------------------------------------------------------------------------} -- | Class for displaying Haskell values. class Display a where- display :: a -> Graphic+ display :: a -> Graphic+ displayIO :: a -> IO Graphic + displayIO = return . display+ instance Display () where display x = x `seq` fromShow x instance Display Graphic where display = id instance Display Bool where display = fromShow@@ -58,6 +64,10 @@ instance Display [Int] where display = displayList instance Display [String] where display = displayList +instance Display a => Display (IO a) where+ display _ = string "<<IO action>>"+ displayIO m = fmap display m+ fromShow :: Show a => a -> Graphic fromShow = string . show @@ -65,13 +75,16 @@ displayList = fromShow {------------------------------------------------------------------------------ Internal Class for displaying either IO actions or values+ Interpreter management ------------------------------------------------------------------------------}-class DisplayIO a where- displayIO :: a -> IO Graphic+refFinalizers :: IORef [IO ()]+refFinalizers = unsafePerformIO $ newIORef [] -instance Display a => DisplayIO (IO a) where- displayIO = fmap display-instance Display a => DisplayIO a where- displayIO = return . display+addFinalizerSession :: IO () -> IO ()+addFinalizerSession m = modifyIORef refFinalizers (m:)++finalizeSession :: IO ()+finalizeSession = do+ sequence_ =<< readIORef refFinalizers+ writeIORef refFinalizers []