From fb8655694f6fbd57f6eb23ed7694ee680102fa22 Mon Sep 17 00:00:00 2001 From: Schell Scivally Date: Wed, 23 Jan 2019 11:49:31 -0800 Subject: [PATCH] monad fail --- package.yaml | 22 ++++++++++++++++++---- src/Typograffiti/GL.hs | 8 ++++---- stack.yaml | 5 +++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/package.yaml b/package.yaml index f8e56df..2c9cf96 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: typograffiti -version: 0.1.0.0 +version: 0.1.0.2 github: "schell/typograffiti" license: BSD3 author: "Schell Scivally" @@ -11,14 +11,28 @@ extra-source-files: - ChangeLog.md # Metadata used when publishing your package -synopsis: Display TTF fonts in OpenGL. Includes caching for fast - rendering. +synopsis: Just let me draw nice text already category: Graphics # To avoid duplicated efforts in documentation and dealing with the # complications of embedding Haddock markup inside cabal files, it is # common to point users to the README.md file. -description: A library that lets you draw nice text already! +description: This is a text rendering library that uses OpenGL + and freetype2 to render TTF font strings quickly. It is + fast enough to render large chunks of text in real + time. This library exists because text rendering is + one of the biggest hurdles in Haskell graphics + programming - and it shouldn't be! + + Typograffiti includes an MTL style typeclass and a + default monad transformer. It does not assume you are + using any specific windowing solution. It does assume + you are using OpenGL 3.3+. + + Pull requests are very welcome :) + + See https://github.com/schell/typograffiti/blob/master/app/Main.hs + for an example. dependencies: - base >= 4.7 && < 5 diff --git a/src/Typograffiti/GL.hs b/src/Typograffiti/GL.hs index 65086fd..7c260e8 100644 --- a/src/Typograffiti/GL.hs +++ b/src/Typograffiti/GL.hs @@ -4,7 +4,8 @@ module Typograffiti.GL where import Control.Exception (assert) -import Control.Monad (forM_, when, replicateM) +import Control.Monad (forM_, replicateM, when) +import Control.Monad.Fail (MonadFail) import Control.Monad.IO.Class (MonadIO (..)) import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as B8 @@ -24,7 +25,7 @@ import Linear import Linear.V (Finite, Size, dim, toV) -allocAndActivateTex :: MonadIO m => GLenum -> m GLuint +allocAndActivateTex :: (MonadIO m, MonadFail m) => GLenum -> m GLuint allocAndActivateTex u = do [t] <- liftIO $ allocaArray 1 $ \ptr -> do glGenTextures 1 ptr @@ -42,8 +43,7 @@ clearErrors str = do assert False $ return () -newBoundVAO - :: MonadIO m => m GLuint +newBoundVAO :: (MonadIO m, MonadFail m) => m GLuint newBoundVAO = do [vao] <- liftIO $ allocaArray 1 $ \ptr -> do glGenVertexArrays 1 ptr diff --git a/stack.yaml b/stack.yaml index 361a2b2..6fc670a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -18,7 +18,8 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-12.10 +#resolver: lts-12.10 +resolver: lts-13.4 # User packages to be built. # Various formats can be used as shown in the example below. @@ -62,4 +63,4 @@ packages: # extra-lib-dirs: [/path/to/dir] # # Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor \ No newline at end of file +# compiler-check: newer-minor -- 2.30.2