packages feed

fir-0.1.0.0: test/Tests/Optics/NestedOfType.hs

{-# LANGUAGE BlockArguments   #-}
{-# LANGUAGE DataKinds        #-}
{-# LANGUAGE PolyKinds        #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators    #-}

module Tests.Optics.NestedOfType where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- setting all components of a given type, nested inside arrays and structures

type S =
  Struct
    '[ "a" ':-> Array 2 Float
     , "b" ':-> Array 3 ( V 2 Float )
     , "c" ':-> Struct '[ "x" ':-> Word32, "y" ':-> Array 2 ( Struct '[ "z" ':-> Float ] ) ]
     , "m" ':-> M 2 2 Float
     ]

type Defs =
  '[ "out"  ':-> StorageBuffer '[ DescriptorSet 0, Binding 0 ] ( Struct '[ "s" ':-> S, "v" ':-> V 2 Float ] )
   , "main" ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
   ]

program :: Module Defs
program = Module do
  entryPoint @"main" @Compute do
    assign @( Name "out" :.: OfType Float ) 5
    assign @( Name "out" :.: Name "s" :.: Name "b" :.: OfType Float ) 3
    assign @( Name "out" :.: OfType ( V 2 Float ) :.: Index 1 ) ( 7 :: Code Float )