iterm-show-diagrams (empty) → 0.1.0.0
raw patch · 7 files changed
+95/−0 lines, 7 filesdep +JuicyPixelsdep +basedep +diagrams-libsetup-changedbinary-added
Dependencies added: JuicyPixels, base, diagrams-lib, diagrams-rasterific, iterm-show
Files
- ChangeLog.md +5/−0
- LICENSE +30/−0
- README.md +10/−0
- Setup.hs +2/−0
- doc/screen-cap.png binary
- iterm-show-diagrams.cabal +23/−0
- src/ITermShow/Diagrams.hs +25/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for iterm-show-diagrams++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2018, Luke Clifton++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Luke Clifton nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,10 @@+# iterm-show-diagrams++This library exports an orphan Show instance for diagrams. +It allows you to view images inline in your terminal if it is supported by+the iterm-show library.++It also includes a function, `draw` which helps you to assign the correct+type for the show instance incase you are using very generic functions.++
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ doc/screen-cap.png view
binary file changed (absent → 130581 bytes)
+ iterm-show-diagrams.cabal view
@@ -0,0 +1,23 @@+name: iterm-show-diagrams+version: 0.1.0.0+synopsis: Orphan Show instances for diagrams package that render inline in some terminals+description:+ This package provides orphan Show instances for the QDiagram type from+ the diagrams package. This allows showing images from the GHCi prompt, which+ is really handy for development and experimentation.+homepage: https://github.com/luke-clifton/iterm-show-diagrams+license: BSD3+license-file: LICENSE+author: Luke Clifton+maintainer: lukec@themk.net+copyright: (c) 2018 Luke Clifton+category: Graphics+build-type: Simple+extra-source-files: ChangeLog.md, README.md, doc/*.png+cabal-version: >=1.10++library+ exposed-modules: ITermShow.Diagrams+ build-depends: base >=4.9 && <4.13, diagrams-lib, iterm-show, JuicyPixels, diagrams-rasterific+ hs-source-dirs: src+ default-language: Haskell2010
+ src/ITermShow/Diagrams.hs view
@@ -0,0 +1,25 @@+{-# LANGUAGE FlexibleInstances, TypeFamilies, OverloadedStrings #-}+module ITermShow.Diagrams where++import Codec.Picture+import Debug.Trace+import Data.Typeable+import ITermShow+import Diagrams.Backend.Rasterific+import Diagrams+import Data.Semigroup++-- | You can use this in a type annotation to get the correct instance.+type ShowDiagram = Diagram B++-- | Convenience function for setting the correct type of a diagram.+draw :: QDiagram b v n m -> QDiagram b v n m+draw = id++instance (b ~ B, v ~ V2, n ~ Double, m ~ Any) => Show (QDiagram b v n m) where+ show =+ let+ opts = RasterificOptions (mkWidth 250)+ in+ displayImageString . encodePng . renderDia Rasterific opts+