mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-12-23 13:06:35 +00:00
0b86356a49
This commit adds the Vulkan backend and SDL2 integration, and provides the `vulkan` example project.
41 lines
992 B
Haskell
41 lines
992 B
Haskell
{-# LANGUAGE BlockArguments #-}
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
module Util where
|
|
|
|
-- base
|
|
import Data.Coerce
|
|
( coerce )
|
|
import Data.Functor.Compose
|
|
( Compose(..) )
|
|
import Data.Functor.Identity
|
|
( Identity(..) )
|
|
import Data.Traversable
|
|
( for )
|
|
|
|
-- transformers
|
|
import Control.Monad.Trans.State.Strict
|
|
( StateT(..), State, evalState )
|
|
import Control.Monad.Trans.Writer.Strict
|
|
( runWriter, tell )
|
|
|
|
---------------------------------------------------------------
|
|
|
|
iunzipWith
|
|
:: (Traversable t, Num i, Enum i)
|
|
=> (i -> a -> b) -> (i -> a -> c) -> t a -> ( t b, [c] )
|
|
iunzipWith f g ta
|
|
= runWriter
|
|
$ ifor 0 succ ta \ i a -> do
|
|
tell [g i a]
|
|
pure ( f i a )
|
|
|
|
ifor
|
|
:: forall t f i a b
|
|
. ( Applicative f, Traversable t )
|
|
=> i -> ( i -> i ) -> t a -> ( i -> a -> f b ) -> f (t b)
|
|
ifor i0 upd ta f = (`evalState` i0) . getCompose $ result
|
|
where
|
|
result :: Compose (State i) f (t b)
|
|
result = for ta \ a -> ( coerce ( \ i -> ( f i a, upd i ) ) )
|