[Haskell-cafe] Seeking advice on a style question
Steve Schafer
steve at fenestra.com
Thu Dec 28 21:41:38 EST 2006
On Tue, 26 Dec 2006 20:21:45 -0800, you wrote:
>How would this example look if you named only multiply-used expressions?
>I'd like to see it in a more conventional pointful style with nested
>expressions. I'm still wondering whether the awkwardness results from your
>writing style or is more inherent. Showing the real variable names may also
>help also.
This is what it looks like "for real":
> process :: Item -> MediaKind -> MediaSize -> Language -> SFO
> process item mediaKind mediaSize language =
> let pagemaster = loadPagemaster item mediaKind mediaSize;
> questions = stripUndisplayedQuestions mediaKind $
> appendEndQuestions item pagemaster $
> coalesceParentedQuestions $
> validateQuestionContent $
> loadQuestions item;
> (numberedQuestions,questionCategories) = numberQuestions pagemaster questions;
> numberedQuestions' = coalesceNAQuestions numberedQuestions;
> (bands,sequenceLayouts) = buildLayout mediaKind language numberedQuestions';
> bands' = resolveCrossReferences bands;
> groupedBands = groupBands bands';
> pages = paginate item mediaKind mediaSize pagemaster groupedBands;
> pages' = combineRows pages;
> sfo = pages' sequenceLayouts;
> in sfo
These are the function signatures:
> loadPagemaster :: Item -> MediaKind -> MediaSize -> Pagemaster
> loadQuestions :: Item -> [Question]
> validateQuestionContent :: [Question] -> [Question]
> coalesceParentedQuestions :: [Question] -> [Question]
> appendEndQuestions :: Item -> Pagemaster -> [Question] -> [Question]
> stripUndisplayedQuestions :: MediaKind -> [Question] -> [Question]
> numberQuestions :: Pagemaster -> [Question] -> ([NumberedQuestion],[QuestionCategory])
> coalesceNAQuestions :: [NumberedQuestion] -> [NumberedQuestion]
> buildLayout :: MediaKind -> Language -> [NumberedQuestion] -> ([Band],[SequenceLayout])
> resolveCrossReferences :: [Band] -> [Band]
> groupBands :: [Band] -> [[Band]]
> paginate :: Item -> MediaKind -> MediaSize -> Pagemaster -> [[Band]] -> [Page]
> combineRows :: [Page] -> [Page]
> createSFO :: [Page] -> [SequenceLayout] -> SFO
MediaKind, MediaSize and Language are simple enumerations; everything
else is a complex structure.
Steve Schafer
Fenestra Technologies Corp.
http://www.fenestra.com/
More information about the Haskell-Cafe
mailing list