idiom for different implementations of same idea
Hal Daume III
hdaume@ISI.EDU
Fri, 2 Aug 2002 12:57:47 -0700 (PDT)
Hi,
> In similar situations, especially if there is more than one useful way to
> use the various parts of an algorithm, I used often prefer existentials:
>
> data Model = forall markup table alignments. Model
> {
> prepareData :: Data () -> Data markup,
> initialize :: Data markup -> ST s table,
> doThingOne :: Data markup -> table -> ST s alignments,
> doThingTwo :: Data markup -> alignments -> ST s table,
> getResults :: Data markup -> table -> alignments -> String
> }
I like this a lot! The only problem is I don't think GHC does. It
complains:
/nfs/isd/hdaume/projects/MESumm/new/Model.hs:13:
Can't combine named fields with locally-quantified type variables
In the declaration of data constructor Model
In the data type declaration for `Model'
....