I was wondering if there is more info on how thee compiling of plutus scripts to plutus core is done. When I look at all examples on github  they are all structured the same.
- There is a script.hs that contains the logic for validation.
- There is a cabal file that says what the build is and how it is done with dependencies.
- There is a main.hs that compiles the script.hs to plutus core.
This is the first time I used a DSL and this way of compiling is new to me. What is unknown to me is how to setup the main.hs to correctly compile the written script to plutus core. I recognize a general structure of each of these fails in the above mentioned repository but can not extract the general way of how this works. Could someone help me with this?
The compilation to Plutus Core occurs in template Haskell code like
$$(PlutusTx.compile [|| helloWorld ||]) in the
Serialization occurs in
PlutusScriptSerialised . SBS.toShort . LBS.toStrict $ serialise helloWorldScript.
main.hs writes the file using code like
writeFileTextEnvelope filename Nothing scriptSerial. A lot of the
main.hs examples do extra things like print execution units, serialize data, etc.
I don’t know of detailed documentation beside the examples and source code, but the essential, general approach is:
PlutusScriptSerialised . SBS.toShort . LBS.toStrict . serialise
Thank you! So if I am correct, the main.hs only has to execute the
writeFileTextEnvelop filename Nothing scriptSerial to correctly compile the template haskell code to a serialized PlutusScriptV1. All other ectra function defined here are for debugging and statistics purposes only. This is clear!