[Haskell-cafe] Why isn't ArrowChoice a parent of of ArrowApply?

2013-06-20 Thread Petr Pudlák

In Control.Arrow we have:

   |leftApp  ::ArrowApply  a = a b c - a (Either  b d) (Either  c d)|

   Any instance of |ArrowApply| can be made into an instance of
   |ArrowChoice| by defining |left = leftApp|.

So why isn't |ArrowChoice| a parent of |ArrowApply|?

Best regards,
Petr

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't ArrowChoice a parent of of ArrowApply?

2013-06-20 Thread Ross Paterson
On Thu, Jun 20, 2013 at 09:02:48AM +0200, Petr Pudlák wrote:
 In Control.Arrow we have:
 
 leftApp :: ArrowApply a = a b c - a (Either b d) (Either c d)
 
 Any instance of ArrowApply can be made into an instance of ArrowChoice by
 defining left = leftApp.
 
 So why isn't ArrowChoice a parent of ArrowApply?

Probably because it wasn't in John Hughes's original paper.
I agree that it would make sense.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The promising world of Monadic formlets

2013-06-20 Thread Alberto G. Corona
Here is the example with better rendering and additional information as
well as some identifies issues to be solved.

http://haskell-web.blogspot.com.es/2013/06/the-promising-land-of-monadic-formlets.html

And  I made strong statements there.

What do you think? If you have questions or want to be involved in
the development of this and other related concepts, please send me a
message.


2013/6/20 Alberto G. Corona agocor...@gmail.com

 I don´t know how, but the google mail has changed the applicative functor
 operator after (,) Left and Rigth by  -.




 2013/6/19 Alberto G. Corona agocor...@gmail.com

 Hi,

 This is just to let you know the promising results of some
 experimentation:

 Formlets are about applicative instances, but what about monadic
 instances? What a Monad instance of formlets means? I recently experimented
 with this and the results are very interesting and powerful- It mixes the
 best of web forms, with the flexibility of console applications. ???!!


 Althoug this example is for the formlets of the MFlow
 https://github.com/agocorona/MFlowframework , it can be ported to
 other formlet implementations. Although the MFLow formlets include web
 formatting that is not supported in other formlets implementations. Static
 HTML templating don´t work well with monadic formlets, so it is important
 to include the formatting as a  part of the computation:

 import MFlow.Wai.Blaze.Html.All

 dynamicForm= wform $ do
   (n,s) - (,) - p  Who are you?
++ getString Nothing  ! hint name ++ br
* getString Nothing  ! hint surname  ++ br
** submitButton ok ++ br

   flag - b  do you  ++ getRadio[radiob work?,radiob study?]
 ++ br

   r-case flag of
  work - pageFlow l
  $ Left  - b  do you enjoy your work? 
 ++ getBool True yes no
 ** submitButton ok  ++ br

  study- pageFlow r
  $ Right - b  do you study in 
   ++ getRadio[radiob University
  ,radiob High School]

   p  (You are ++n++ ++s) ++
case r of
  Left fl -   p  (You work and it is  ++ show fl ++  that
 you enjoy your work)
 ++ noWidget

  Right stu - p  (You study at the  ++ stu)
 ++ noWidget


 hint s= [(placeholder,s)]
 onClickSubmit= [(onclick,this.form.submit())]
 radiob s n= text s ++ setRadio s n ! onClickSubmit

 Here wform, getBool, getString , getRadio etc are formlet elements

 The first sentence is an applicative composition that generate a 2 tuple,
 to show that applicative and monadic can be mixed.  the operations ++ add
 html to the formlet. the operatior ! add attributes to the formlet
 element.. noWidget is a dumb formlet that does not validate.

 The second monadic statement is an election between two options. The
 beauty of the monadic instance is that the rest of the form can vary
 depending on the previous answers.  Since the formlets validate the input,
 unless the election is made, the radio will not validate, so the monadic
 execution will be aborted beyond any unanswered question, so nothing will
 appear after the question. The rest of the form will appear when the user
 choose one of the two options. once one or the other option is chosen, then
 another binary question is presented. (either he likes his work or where he
 study).  When the questions are finised, the results are presented.
 I hope that you get the idea. The benefit is not only the familiar coding
 and presentation of a sequential console application: Since the form
 encloses all the fields, At any time the user can change previous inputs
 and the form will reflect these changes. For example if the user change
 from work to study (second statements) the where do you study will appear
 and the work related questions and answers will disappear. That is
 wonderfully useful for heavily interactive applications.

 There is  a problem however and it is the issue of the formlet
 identifiers. Unlike in an applicative presentation, now the number and type
 of the formlets will vary, so the response to a previous form create a new
 kind of form, and the post response can be misinterpreted. To avoid that ,
 the  pageFlow call creates fixed field labels for each branch of execution.

 I will release a version of MFlow that support this kind of monadic
 composition of fomlets, but In essence it is nothing but to add Monad
 instance to formlets. A single server procedure, that executes the formlet
 code can support all the interaction so any framework can do it. The
 usability of that is huge:It is possible to interact in a web page in a
 console style with questions and answers with the versatitly of a dynamic
 foms: Any modification in the form change the subsequent flow of
 interaction. Another application of this monadic 

Re: [Haskell-cafe] TH clause Pat selection

2013-06-20 Thread Geoffrey Mainland
Have you tried dataToPatQ and dataToExpQ?

http://hackage.haskell.org/packages/archive/template-haskell/latest/doc/html/Language-Haskell-TH-Quote.html

Geoff

On 06/19/2013 11:23 PM, Brian Lewis wrote:
 I want to use TH to generate functions like
 foo :: c - h
 foo ... = ...
 foo ... = ...
 ...
 from lists of pairs :: [(c, h)]

 For example, $(genFoo ''Int ''Bool [(0,False), (1,True)])
 would generate
 foo 0 = False
 foo 1 = True

 The problem is, I don't know how to generate the function's clauses.
 foo 0 = ... seems to be a LitP pattern. But foo True = ... seems to
 be a ConP pattern. The appropriate pattern depends on type c.

 Here's code with more explanation and examples:
 http://hpaste.org/90163

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: haskell-names-0.1

2013-06-20 Thread Roman Cheplyaka
I am pleased to announce the first public release of haskell-names, a
name resolution library for haskell-src-exts AST.

Namely, it can do the following:

*   for a module, compute its interface, i.e. the set of entities
exported by the module, together with their original names.

*   for each name in the module, figure out what it refers to — whether
it's bound locally (say, by a where clause) or globally (and then
give its origin).

Thanks to haskell-packages, this library is fully integrated with Cabal,
so that you can easily generate name interfaces for any Cabalized package.

See more details in the README:
http://documentup.com/haskell-suite/haskell-names

This library is based on the code written by Lennart Augustsson in 2010.
Little of that code survived, but nevertheless it's been a great help.

Roman

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Ann: Cascading 0.1.0, DSL for Cascading Style Sheets

2013-06-20 Thread Ertugrul Söylemez
Hi there,

I've just released the first version of [cascading], library for
writing/generating Cascading Style Sheets (CSS) in Haskell.  The API
design is inspired by many other projects, including blaze-html, HSP and
Yesod's Lucius.

[cascading]: http://hackage.haskell.org/package/cascading

Features:

  * Style sheets are monoids and can be MonadWritered.

  * All non-appendix properties of CSS level 2.1 are implemented and
exposed through a type-safe API.  It's easy enough to set properties
for which no type-safe API exists.  See the example below.

  * Easy to integrate into all monadic web frameworks, easy to
interleave stylesheets with framework operations.

  * Builtin support for web-routes.

  * Color space awareness through the colour library.

  * Fully encoding-aware with one caveat:  If you bypass PropValue and
use ByteStrings as property values directly, then UTF-8 is assumed.

Example:

stylesheet :: (MonadWriter CSS m) = m ()
stylesheet =
onAll $ do
select [p] $ do
margin . Edges $ [zeroLen]
padding . Edges $ [_Em # 1, _Ex # 2]

select [em] $ do
fontWeight BolderWeight

select [ul, ol] . below [li] $ do
borderColor (LeftEdge green)
borderWidth (LeftEdge ThickWidth)
vendors $ borderRadius $= (3mm :: PropValue)

This results in the following stylesheet:

p { margin: 0;
padding: 1em 2ex }

em { font-weight: bolder }

ul li, ol li {
border-left-color: #008000;
border-left-width: thick;
border-radius: 3mm;
-moz-border-radius: 3mm;
-ms-border-radius: 3mm;
-o-border-radius: 3mm;
-webkit-border-radius: 3mm
}

Please visit the [homepage].  Feedback is always welcome.  If you find
bugs, please don't hesitate to [report] them.

[homepage]: http://hub.darcs.net/ertes/cascading
[report]:   http://hub.darcs.net/ertes/cascading/issues


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.


signature.asc
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ann: Cascading 0.1.0, DSL for Cascading Style Sheets

2013-06-20 Thread Ertugrul Söylemez
Ertugrul Söylemez e...@ertes.de wrote:

 vendors $ borderRadius $= (3mm :: PropValue)

Typo: vendors $ border-radius $= (3mm :: PropValue)


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.


signature.asc
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TH clause Pat selection

2013-06-20 Thread Ozgur Akgun
Hi.

On 19 June 2013 23:23, Brian Lewis br...@lorf.org wrote:

 The problem is, I don't know how to generate the function's clauses.
 foo 0 = ... seems to be a LitP pattern. But foo True = ... seems to
 be a ConP pattern. The appropriate pattern depends on type c.


I've used haskell-src-meta for this purpose before. See:

http://hackage.haskell.org/packages/archive/haskell-src-meta/0.6.0.2/doc/html/Language-Haskell-Meta-Parse.html#v:parsePat

Hope this helps,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe