[Haskell-cafe] Seeking for an extention (functional incapsulation)
Belka
lambda-belka at yandex.ru
Thu Aug 6 19:13:06 EDT 2009
Hello, cafe visitors! :)
This is a double topic:
1. Can't find any good informative resource with descriptions of Haskell
extensions. Could anybody please share good one if it exists?
The only "good" one I found:
http://hackage.haskell.org/trac/haskell-prime/wiki/HaskellExtensions
But it's a bit too old and not that full...
I undestand, that Haskell is kind of "boiling" language, in a sense of being
neverending experiment. It develops all the time, extensions show up and
drop out. So it's not that easy to support community with a fresh
information about them. But on the other side, the property (of being
"boiling" language) makes such information really important for community
members... I think. :)
2. Consider situation:
-----------------------------------
data SomeDataType = SomeDataType { sdtField1 :: SDT_Field1Type, sdtField2 ::
SDT_Field2Type}
sdtField3 :: SomeDataType -> SDT_Field3Type
sdtField3 sdt = f (sdtField1 sdt) (sdtField2 sdt)
-----------------------------------
I induced recently, that it would be very comfortable if I could perform in
a way like this:
-----------------------------------
data SomeDataType = SomeDataType { sdtField1 :: SDT_Field1Type, sdtField2 ::
SDT_Field2Type, sdtField3 :: SDT_Field2Type, sdtField3 = f sdtField1
sdtField2}
-----------------------------------
The situation is not that rare, when dealing with nonprimitive data
constructions. Moreover would be really comfortable to reduce
-----------------------------------
data SomeDataType = SomeDataType_111 { sdtField1 :: SDT_Field1Type,
sdtField2 :: SDT_Field2Type} | SomeDataType_222 { sdtField1 ::
SDT_Field1Type, sdtField2 :: SDT_Field2Type, sdtField5 :: SDT_Field5Type}
sdtField3 :: SomeDataType -> SDT_Field3Type
sdtField3 sdt = case sdt of {SomeDataType_111 -> f (sdtField1 sdt)
(sdtField2 sdt) ; SomeDataType_222 -> g (sdtField1 sdt) (sdtField2 sdt)
(sdtField5 sdt)}
\/ \/ \/ \/ \/ \/ \/ \/ \/ \/
data SomeDataType = SomeDataType_111 { sdtField1 :: SDT_Field1Type,
sdtField2 :: SDT_Field2Type, sdtField3 :: SDT_Field3Type, sdtField3 = f
sdtField1 sdtField2} | SomeDataType_222 { sdtField1 :: SDT_Field1Type,
sdtField2 :: SDT_Field2Type, sdtField5 :: SDT_Field5Type, sdtField3 ::
SDT_Field3Type, sdtField3 = g sdtField1 sdtField2 sdtField5}
-----------------------------------
Usable mechanics for realization would be:
1. Funtion similar to Data.Function.on (example: (*) `on` f = \x y -> f x *
f y), but opposite - I called it under.
t `under` f = \x y -> (x f) `t` (y f)
2. currying and uncurrying
Is there any such extension?
Belka
--
View this message in context: http://www.nabble.com/Seeking-for-an-extention-%28functional-incapsulation%29-tp24856249p24856249.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list