Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

Create a `ChunkDB` that all case studies import and add to.

Open balacij opened this issue 7 months ago • 2 comments

Code Duplication

Look at these examples:

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs#L153-L163

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs#L63-L67

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs#L107-L116

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/dblpend/lib/Drasil/DblPend/Body.hs#L144-L152

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs#L134-L143

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/sglpend/lib/Drasil/SglPend/Body.hs#L132-L140

https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/template/lib/Drasil/Template/Body.hs#L108-L114

Goal

Each of our case studies have a basic set of chunks that we seem to always add to the ChunkDB for all of our case studies. The goal of this issue is to reduce the amount of duplication between ChunkDBs.

Solution

We can do this in at least two ways:

  1. Create a ChunkDB containing much of the stuff we import in at least 2 of our case studies, and use that as a basis for our other cdbs.
  2. Create a cdbWCommons function that wraps cdb by injecting the same common imports to the relevant lists before also using cdb to create the ChunkDB.

balacij avatar May 30 '25 18:05 balacij

I found something that already does something similar to (1), could we build on this? https://github.com/JacquesCarette/Drasil/blob/196370e5a3ca95d9be69f9155f6c664dda897f5a/code/drasil-example/template/lib/Drasil/Template/Body.hs#L108-L114 I'm not sure if drasil-example/template is meant to be accessed at all but the code could at least be copied to somewhere more appropriate @balacij

jackwyand avatar May 30 '25 19:05 jackwyand

Good find @jackwyand

We should first analyze what's going on with the pattern. Is it all meta-information? If so, then clearly we should abstract it out. In a way, that information should always be present even in an empty ChunkDB! It's like our Prelude.

JacquesCarette avatar May 30 '25 20:05 JacquesCarette