[Haskell-cafe] Seeking for an extention (functional incapsulation)

Dan Weston westondan at imageworks.com
Thu Aug 6 20:55:21 EDT 2009


 > the value grows exponentially with LOC (lines of code) count. :)

Exponentially? Now I'm missing something...

Your way has 156 chars:
data SomeDataType = SomeDataType { sdtField1 :: SDT_Field1Type, sdtField2 ::
 > SDT_Field2Type, sdtField3 :: SDT_Field2Type, sdtField3 = f sdtField1
 > sdtField2}

This way has 162 chars:
data SomeDataType = SomeDataType { sdtField1 :: SDT_Field1Type, 
sdtField2 :: SDT_Field2Type}
sdtField3 :: SDT_Field2Type
sdtField3 = f <$> sdtField1 <*> sdtField2

This adds 6 characters per dependent deconstructor function. As a 
fraction of total LOC, this is insignificant.

Belka wrote:
> Thank you, for your reply, Dan! :)
> 
>> You don't really need this inline in the record syntax, do you?
> In fact, that was the point. To enclose direct functional dependants into
> the record declaration. To achieve better pithiness - it's valuable, and the
> value grows exponentially with LOC (lines of code) count. :)
> 
>> sdtField3 sdt = f <$> sdtField1 <*> sdtField2
> Doesn't look much better than my "under" function (t `under` f = \x y -> (x
> f) `t` (y f)). What did I miss?
> I believe, there are good reasons to use Control.Applicative for lots
> purposes, but unfortunately, yet haven't had time to try it in my practice.
> 
> Belka



More information about the Haskell-Cafe mailing list