[FRIAM] Literate CoffeeScript

2013-02-25 Thread Owen Densmore
(This may be a bit odd for some of us, but I wanted to pass on a novel
innovation)

The latest release of coffeescript has a new Literate mode: if you use
the extension .litcoffee it is also treated as markdown!  This is a modern
extension to Knuth's Literate Programming:
  http://www-cs-faculty.stanford.edu/~uno/lp.html

This is likely brought about by the coffeescript docco documentation tool,
but now integrated into the coffeescript compiler.

I've been imbedding markdown in agentscript for docco use once the project
got real.  You can see it here:

http://htmlpreview.github.com/?https://raw.github.com/backspaces/agentscript/master/docs/model.html
I wasn't sure initially, but now am entirely sold on the approach.  For one
thing it has been invaluable for discussing the project with other
programmers wishing to modify the code.

The literate coffeescript announcement is here, with links showing the
source in various formats:
 http://coffeescript.org/#literate

As odd as it may seem, I recommend use of similar stunts in all languages
that support it.  Knuth has quite a following in this area.  The idea of
markdown comments certainly has a lot of traction.

( Now back to our scheduled .. er.. programming! :)

   -- Owen

Literate CoffeeScript

Besides being used as an ordinary programming language, CoffeeScript may
also be written in literate mode. If you name your file with a
.litcoffee extension,
you can write it as a Markdown document — a document that also happens to
be executable CoffeeScript code. The compiler will treat any indented
blocks (Markdown's way of indicating source code) as code, and ignore the
rest as comments.

Just for kicks, a little bit of the compiler is currently implemented in
this fashion: See it as a
documenthttps://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df
, 
rawhttps://raw.github.com/jashkenas/coffee-script/master/src/scope.litcoffee,
and properly highlighted in a text editor http://cl.ly/LxEu.

I'm fairly excited about this direction for the language, and am looking
forward to writing (and more importantly, reading) more programs in this
style. As *1.5.0* is the first version of CoffeeScript that supports it,
let us know if you have any ideas for improving the feature.

FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com

Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread mar...@snoutfarm.com
So sad, and so unnecessary..

https://github.com/faylang/fay/wiki
http://www.haskell.org/haskellwiki/Literate_programming



mail2web - Check your email from the web at
http://link.mail2web.com/mail2web




FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread Russ Abbott
Haskell is a wonderful language. But it is (obviously) functional, which
means no side effects. The primary purpose of a language like JavaScript is
to produce side-effects that change the DOM and what is displayed by a
browser. How does Fay get around that seeming incompatibility in objectives?


*-- Russ Abbott*
*_*
***  Professor, Computer Science*
*  California State University, Los Angeles*

*  My paper on how the Fed can fix the economy: ssrn.com/abstract=1977688*
*  Google voice: 747-*999-5105
  Google+: plus.google.com/114865618166480775623/
*  vita:  *sites.google.com/site/russabbott/
  CS Wiki http://cs.calstatela.edu/wiki/ and the courses I teach
*_*


On Mon, Feb 25, 2013 at 12:11 PM, mar...@snoutfarm.com mar...@snoutfarm.com
 wrote:

 So sad, and so unnecessary..

 https://github.com/faylang/fay/wiki
 http://www.haskell.org/haskellwiki/Literate_programming


 
 mail2web - Check your email from the web at
 http://link.mail2web.com/mail2web



 
 FRIAM Applied Complexity Group listserv
 Meets Fridays 9a-11:30 at cafe at St. John's College
 to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com

Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread mar...@snoutfarm.com
Russ wrote:

But it is (obviously) functional, which
means no side effects. The primary purpose of a language like JavaScript is
to produce side-effects that change the DOM and what is displayed by a
browser. How does Fay get around that seeming incompatibility in
objectives?

Haskell deals with side-effects using Monads.  Las Vegas is like a Monad: 
What happens in Vegas, stays in Vegas.   The idea is your DOM would be an
opaque type that could be returned by a function, but its state is not
revealed.  In this way, there are no side effects outside of the global
object that is returned.

http://hackage.haskell.org/package/fay-dom
http://www.haskell.org/haskellwiki/Monad


myhosting.com - Premium Microsoft® Windows® and Linux web and application
hosting - http://link.myhosting.com/myhosting




FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread Russ Abbott
That's fine, but it seems strange to promote a language because one of its
features lets you work around its primary objective.


*-- Russ Abbott*
*_*
***  Professor, Computer Science*
*  California State University, Los Angeles*

*  My paper on how the Fed can fix the economy: ssrn.com/abstract=1977688*
*  Google voice: 747-*999-5105
  Google+: plus.google.com/114865618166480775623/
*  vita:  *sites.google.com/site/russabbott/
  CS Wiki http://cs.calstatela.edu/wiki/ and the courses I teach
*_*


On Mon, Feb 25, 2013 at 2:44 PM, mar...@snoutfarm.com
mar...@snoutfarm.comwrote:

 Russ wrote:

 But it is (obviously) functional, which
 means no side effects. The primary purpose of a language like JavaScript is
 to produce side-effects that change the DOM and what is displayed by a
 browser. How does Fay get around that seeming incompatibility in
 objectives?

 Haskell deals with side-effects using Monads.  Las Vegas is like a Monad:
 What happens in Vegas, stays in Vegas.   The idea is your DOM would be an
 opaque type that could be returned by a function, but its state is not
 revealed.  In this way, there are no side effects outside of the global
 object that is returned.

 http://hackage.haskell.org/package/fay-dom
 http://www.haskell.org/haskellwiki/Monad

 
 myhosting.com - Premium Microsoft® Windows® and Linux web and application
 hosting - http://link.myhosting.com/myhosting



 
 FRIAM Applied Complexity Group listserv
 Meets Fridays 9a-11:30 at cafe at St. John's College
 to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com

Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread mar...@snoutfarm.com
That's fine, but it seems strange to promote a language because one of its
features lets you work around its primary objective.

Nope.  Monads are a purely functional construct.  A elegant generalization,
Arrows, enable one to construct Unix-style pipelines, but with typed
contracts.  That is, imagine having a command shell that rejected as bad
syntax pipelines where the data of the consumer and producer did not make
sense together.  

Marcus


myhosting.com - Premium Microsoft® Windows® and Linux web and application
hosting - http://link.myhosting.com/myhosting




FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread glen
mar...@snoutfarm.com wrote at 02/25/2013 02:57 PM:
 Nope.  Monads are a purely functional construct.  A elegant generalization,
 Arrows, enable one to construct Unix-style pipelines, but with typed
 contracts.  That is, imagine having a command shell that rejected as bad
 syntax pipelines where the data of the consumer and producer did not make
 sense together.

You mean I wouldn't be allowed to listen to the smooth sounds of:

echo main(t){for(t=0;;t++)putchar(t*((t9|t13)25t6));} | gcc
-xc -  ./a.out | aplay

-- 
== glen e. p. ropella
You gotta help me, help me to shake off



FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread Marcus G. Daniels

On 2/25/13 5:31 PM, glen wrote:

mar...@snoutfarm.com wrote at 02/25/2013 02:57 PM:

Nope.  Monads are a purely functional construct.  A elegant generalization,
Arrows, enable one to construct Unix-style pipelines, but with typed
contracts.  That is, imagine having a command shell that rejected as bad
syntax pipelines where the data of the consumer and producer did not make
sense together.

You mean I wouldn't be allowed to listen to the smooth sounds of:

echo main(t){for(t=0;;t++)putchar(t*((t9|t13)25t6));} | gcc
-xc -  ./a.out | aplay
Here's an example taken from YampaSynth, a domain-specific language for 
sound synthesis built using the concepts of Functional Reactive 
Programming.  The pipeline is all in Haskell, all the way to the OpenAL 
output.  (No cheating with an external command line program.)


http://www.haskell.org/haskellwiki/Arrow
http://www.cs.rit.edu/~eca7215/frp-independent-study/Survey.pdf
http://www.haskell.org/haskellwiki/Yampa
http://hackage.haskell.org/package/YampaSynth

Here's a couple sounds.  `scifi' is a whirly-gig sort of sound, and 
`scale' is just a set of sequential notes.

{-# LANGUAGE Arrows #-}

module Main where

import qualified SynthBasics as Synth
import qualified Data.Audio as Audio
import Player.OpenAL (play)
import FRP.Yampa

sciFi :: SF () Audio.Sample
sciFi = proc () - do
  und   - arr (*0.2)  Synth.oscSine 3.0  - 0
  swp   - arr (+1.0)  integral - -0.25
  audio - Synth.oscSine 440   - und + swp
  returnA - audio

envBell :: SF (Event ()) (Synth.CV, Event ())
envBell = Synth.envGen 0 [(0.05,1),(1.5,0)] Nothing

bell :: Synth.Frequency - SF () (Audio.Sample, Event ())
bell f = proc () - do
  m- Synth.oscSine (2.33 * f)  - 0
  audio- Synth.oscSine f   - 2.0 * m
  (ampl, end)  - envBell   - noEvent
  returnA - (audio * ampl, end)

scale :: SF () (Audio.Sample, Event ())
scale =  (  afterEach  [  (0.0, 60), (1.0, 62), (1.0, 64),
  (1.0, 65), (1.0, 67), (1.0, 69),
  (1.0, 71), (1.0, 72)]
  constant ()
  arr (fmap (\k - (bell $ toFreq k)  arr fst))
 rSwitch (constant 0))
  after 8 ()

toFreq :: Int - Double
toFreq n = 440.0 * (2.0 ** (((fromIntegral n) - 69.0) / 12.0))

main :: IO ()
main = do
  let playIt = play 44100 5 1
  -- playIt (sciFi  after 5 ())
  playIt scale
  return()



FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


Re: [FRIAM] Literate CoffeeScript

2013-02-25 Thread Marcus G. Daniels

On 2/25/13 5:31 PM, glen wrote:
You mean I wouldn't be allowed to listen to the smooth sounds of: echo 
main(t){for(t=0;;t++)putchar(t*((t9|t13)25t6));} | gcc -xc - 
 ./a.out | aplay 


I should not let this slip-by without acknowledging that this is a 
functional program.  +1 for that!


Marcus


FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com