Tillmann Rendel <rendel at informatik.uni-marburg.de> wrote:
> Of course, this would need some type hackery à la PrintF to make set
> accept multiple arguments, and the proliferation of such type hackery
> may seem unfortunate. On the other hand, the hackery could possibly be
> encapsulated in a combinator like
>> polyvariadic :: Poly a b c => ([a] -> b) -> c
>> so that layoutSet can be implemented as
>> layoutSet widget = polyvariadic (set widget).
I could think of a layout-based keyword to construct Alternative values,
which wouldn't require type hackery. Something like this:
acat
a
b
c
which would be equivalent to
a <|> b <|> c
Then you could write:
layoutSet myButton $ acat
[text := "Ok"]
[on action := doSomething]
Occasionally this would be very useful for parsers:
numericWord = acat
try $ 1 <$ string "one"
try $ 2 <$ string "two"
try $ 3 <$ string "three"
This together with layout-based function application could be great
syntactical features. Firstly it would be strictly optional, so you
could still program without or with less layout, if you prefer.
Secondly you could get rid of a number of other keywords this way, most
notably the 'if', 'then' and 'else' keywords.
Some people like 'then' and 'else'. So instead of completely removing
them, you can turn them into functions instead:
newtype Then a = Then a
newtype Else a = Else a
if :: Bool -> Then a -> Else a -> a
then :: a -> Then a
else :: a -> Else a
if condition $$
then thisIfTrue
else thisIfFalse
The benefit is that 'if', 'then' and 'else' aren't keywords anymore and
can be used for other purposes in narrow scopes. Sometimes this would
be useful.
Greets
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/