To get another perspective, let's eliminate some unnecessary naming and see what linear pipelines emerge:<br><blockquote style="font-family: courier new,monospace;">process item mediaKind mediaSize language =<br> let (numberedQuestions,questionCategories) =
<br> numberQuestions pagemaster $<br> stripUndisplayedQuestions mediaKind $<br> appendEndQuestions item<br> (loadPagemaster item mediaKind mediaSize) $<br> coalesceParentedQuestions $<br>
validateQuestionContent $<br> loadQuestions item<br> (bands,sequenceLayouts) =<br> buildLayout mediaKind language $<br> coalesceNAQuestions $<br> numberedQuestions<br> in<br> flip combineRows sequenceLayouts $
<br> paginate item mediaKind mediaSize pagemaster $<br> groupBands $<br> resolveCrossReferences $<br> bands<br></blockquote>Warning: I haven't tried to type-check and may have made a clerical error. Since questionCategories isn't used, use "fst" & eliminate another let. Then, for my personal preference, and just to mix things up, switch to "where" style:
<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">process item mediaKind mediaSize language =</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
flip combineRows sequenceLayouts $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> paginate item mediaKind mediaSize pagemaster $</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> groupBands $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> resolveCrossReferences $</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bands</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> where</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (bands,sequenceLayouts) =</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> buildLayout mediaKind language $</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> coalesceNAQuestions $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
fst $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> numberQuestions pagemaster $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
stripUndisplayedQuestions mediaKind $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> appendEndQuestions item</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (loadPagemaster item mediaKind mediaSize) $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> coalesceParentedQuestions $
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> validateQuestionContent $</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
loadQuestions item</span><br></div><br>Not quite a work of art yet, but the structure is getting clearer to me.<br><br><br><br><br><div><span class="gmail_quote">On 12/28/06, <b class="gmail_sendername">Steve Schafer
</b> <<a href="mailto:steve@fenestra.com">steve@fenestra.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Tue, 26 Dec 2006 20:21:45 -0800, you wrote:
<br><br>>How would this example look if you named only multiply-used expressions?<br>>I'd like to see it in a more conventional pointful style with nested<br>>expressions. I'm still wondering whether the awkwardness results from your
<br>>writing style or is more inherent. Showing the real variable names may also<br>>help also.<br><br>This is what it looks like "for real":<br><br>> process :: Item -> MediaKind -> MediaSize -> Language -> SFO
<br>> process item mediaKind mediaSize language =<br>> let pagemaster = loadPagemaster item mediaKind mediaSize;<br>> questions = stripUndisplayedQuestions mediaKind $<br>> appendEndQuestions item pagemaster $
<br>> coalesceParentedQuestions $<br>> validateQuestionContent $<br>> loadQuestions item;<br>> (numberedQuestions,questionCategories) = numberQuestions pagemaster questions;
<br>> numberedQuestions' = coalesceNAQuestions numberedQuestions;<br>> (bands,sequenceLayouts) = buildLayout mediaKind language numberedQuestions';<br>> bands' = resolveCrossReferences bands;
<br>> groupedBands = groupBands bands';<br>> pages = paginate item mediaKind mediaSize pagemaster groupedBands;<br>> pages' = combineRows pages;<br>> sfo = pages' sequenceLayouts;
<br>> in sfo<br><br>These are the function signatures:<br><br>> loadPagemaster :: Item -> MediaKind -> MediaSize -> Pagemaster<br>> loadQuestions :: Item -> [Question]<br>> validateQuestionContent :: [Question] -> [Question]
<br>> coalesceParentedQuestions :: [Question] -> [Question]<br>> appendEndQuestions :: Item -> Pagemaster -> [Question] -> [Question]<br>> stripUndisplayedQuestions :: MediaKind -> [Question] -> [Question]
<br>> numberQuestions :: Pagemaster -> [Question] -> ([NumberedQuestion],[QuestionCategory])<br>> coalesceNAQuestions :: [NumberedQuestion] -> [NumberedQuestion]<br>> buildLayout :: MediaKind -> Language -> [NumberedQuestion] -> ([Band],[SequenceLayout])
<br>> resolveCrossReferences :: [Band] -> [Band]<br>> groupBands :: [Band] -> [[Band]]<br>> paginate :: Item -> MediaKind -> MediaSize -> Pagemaster -> [[Band]] -> [Page]<br>> combineRows :: [Page] -> [Page]
<br>> createSFO :: [Page] -> [SequenceLayout] -> SFO<br><br>MediaKind, MediaSize and Language are simple enumerations; everything<br>else is a complex structure.<br><br>Steve Schafer<br>Fenestra Technologies Corp.
<br><a href="http://www.fenestra.com/">http://www.fenestra.com/</a><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>