diff options
Diffstat (limited to 'Graphics/Glyph/BufferBuilder.hs')
-rw-r--r-- | Graphics/Glyph/BufferBuilder.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Graphics/Glyph/BufferBuilder.hs b/Graphics/Glyph/BufferBuilder.hs index 9dae0aa..b23f6ba 100644 --- a/Graphics/Glyph/BufferBuilder.hs +++ b/Graphics/Glyph/BufferBuilder.hs @@ -104,7 +104,17 @@ instance Show (CompiledBuild x) where show (CompiledBuild stride enabled n ptr nbytes) = "[CompiledBuild stride="++!stride++" enabled"++!enabled++" n="++!n++" ptr="++!ptr++" nbytes="++!nbytes++"]" -instance (Num t) => Monad (BuilderM t) where +instance Functor (BuilderM t) where + fmap f b = b >>= (return . f) + +instance Applicative (BuilderM t) where + pure = return + (<*>) afn aa = do + fn <- afn + a <- aa + return (fn a) + +instance Monad (BuilderM t) where (BuilderM !builder1 _) >> (BuilderM !builder2 ret) = BuilderM (builder1 ><> builder2) ret where @@ -118,7 +128,6 @@ instance (Num t) => Monad (BuilderM t) where b1@(BuilderM _ ret) >>= func = b1 >> func ret return = BuilderM (LeafBuilder Seq.empty) - fail = undefined instance Functor Builder where fmap f (Builder b1 b2) = (Builder (fmap f b1) (fmap f b2)) |