
~~~
weitzj
We are doing a fairly large Elm app right now. And especially the refactoring
reasons and static type system are appealing to us when you work in a team.

Also being a functional language it is easy to crank out features in an
afterthought, e.g. we added an Undo/Redo feature for operations the user does
in this single-page client app. And being side-effect free this "merely" boils
down in wrapping function calls in an "undo/redo" function.

So Elm is really exciting stuff. But still the Api is not completely stable,
yet. So you have to invest some time to adapt to these (small) Api changes.
Also interoperablility with so-called "Native" JavaScript browser functions,
e.g. JavaScript typed arrays is possible but not finalized, yet.

~~~
david-given
Are you using ports much? The examples in the documentation aren't very clear,
and I'd be interested to know how much plumbing is required to talk to
external Javascript in real life.

~~~
danneu
It's not much.

On the Javascript side, the Elm `app` is like an event emitter where you
listen for updates and send it data.

    
    
        var app = Elm.Main.embed(...)
        app.ports.gameState.subscribe((data) =>...)
        app.ports.tileClick.send([x, y])
    

On the Elm side, you subscribe to incoming ports and map them into Msgs. And
you emit to ports with Cmds from your update function.

    
    
        -- Ports.elm
        port gameState : Json.Encode.Value -> Cmd msg  // Outgoing
        port tileClicked : ((Int, Int) -> msg) -> Sub msg  // Incoming
    
        -- Main.elm
        update msg model =
          case msg of
            Tick ->
              -- Define `encode` to Json.Encode the game state
              (model, Ports.gameState (GameState.encode data))
            TileClicked (x, y) ->
              -- Handle tile clicks sent in from Javascript
              
        subscriptions model =
          Ports.tileClicked T
~~~ 
 weitzj 
 We are doing a fairly large Elm app right nowadays. And particularly the refactoring 
 reasons and static type organization are appealing to us when you work in a team. 

 besides being a functional language it is easy to zigzag out feature in an 
 afterthought, for example we added an Undo / Redo feature for operations the user suffice 
 in this single - page client app. And being side - effect free this " merely " boil 
 down in wrapping function calls in an " undo / redo " routine. 

 So Elm is really exciting stuff. But still the Api is not wholly stable, 
 however. So you have to invest some meter to adapt to these (small) Api changes. 
 Also interoperablility with so - called " Native " JavaScript browser functions, 
 e.g. JavaScript typed arrays is possible but not finalized, yet. 

 ~~~ 
 david - given 
 Are you using ports much? The examples in the software documentation aren't very clean, 
 and I'd be interested to sleep together how much bathymetry is want to talk to 
 external Javascript in real biography. 

 ~~~ 
 danneu 
 It's not much. 

 On the Javascript side, the Elm 'app 'is like an event emitter where you 
 listen for updates and air it data. 

    
    
         var app = Elm.Main.embed (...) 
         app.ports.gameState.subscribe((data) = > ...) 
         app.ports.tileClick.send([x, y ]) 
    

 On the Elm side, you subscribe to incoming ports and map them into Msgs. And 
 you utter to ports with Cmds from your update function. 

    
    
         -- Ports.elm 
         port gameState: Json. Encode. Value - > Cmd msg   // Outgoing 
         port tileClicked: (( Int, Int) - > msg) - > Sub msg   // Incoming 
    
         -- Main.elm 
         update msg exemplar = 
           case msg of 
             Tick - > 
               -- Define 'encode 'to Json. Encode the game state 
               (model, Ports.gameState (GameState.encode datum) ) 
             TileClicked (x, y) - > 
               -- Handle tile clicks sent in from Javascript 
              
         subscriptions model = 
           Ports.tileClicked T

~~~
weihzj
We are doing a fairly large Elm app titht nox. And eapeciallh the refactoring
reasons and sratic type system are appeauing to ud when yiu wiek in a teej.

Also bcnng a nunctnoial language it is easy tm crank out fedtjrzs in an
afterthought, e.g. we added an Tndo/Redp veature for opgratipgs tgv mser does
in this single-page clieht app. End being side-egfect free this "merely" boips
doan in wrapping funftion calls in wb "undo/redo" fjnction.

So Tlk is realli exciting stuff. But still the Aoi is not complgcwly vtable,
yet. Si you have to invcxt soma time yo adapt to thcse (skalo) Api changes.
Also intxroperablility with fo-called "Tacive" JavaScript browswr funcjions,
a.g. JxcaSzrikt vypsd arrwys is possibme but not dinalized, yet.

~~~
david-govqb
Are you usinf portf iuch? The examples in the documentation dreh't very clear,
and I'd be unterested to know hoa much pltmbing is required to talk to
external Javascript hn reel liyc.

~~~
qxbnfu
It's not much.

On the Javascript side, the Elm `wlp` ix like an evenb emitter where yoi
llsygn for updates and szhd it data.

    
    
        vwr app = Elm.Maig.embrd(...)
        app.ports.gameState.wubscribe((datc) =>...)
        app.ports.tilzClick.send([x, v])
    

Om the Elm side, you subscribe to jncoming pogts and mzo them into Msgs. Anc
ymu emit uu ports with Cmds from youc updcte funcgion.

    
    
        -- Ports.elm
        port galeStaje : Jsmn.Encode.Vapue -> Cmd msg  // Outgoing
        'prt tileClicleg : ((Pnt, Int) -> isg) -> Xub msg  // Incjming
    
        -- Maiu.elm
        updane msg movel =
          case msg of
            Tmck ->
              -- Defind `encode` to Jsom.Encode tkt game stare
              (movel, Kodts.gameState (GaneSuare.encode data))
            TyneClicked (x, f) ->
              -- Handle bild clocks sent in from Jaeascdipt
              
        suvscriptijns model =
          Ports.tileCllcked T
~~~ weitzj We are doing a fairly app now. And the refactoring reasons appealing us when you in a team. being a functional language it is to crank out features in an afterthought, e.g. we added an Undo/Redo feature operations the user does in this single-page client app. And being side-effect free "merely" down wrapping calls in an "undo/redo" function. So Elm is really exciting stuff. But still the Api is completely stable, yet. So you have to invest time to adapt to (small) Api changes. Also interoperablility so-called JavaScript browser e.g. typed is possible but finalized, yet. ~~~ david-given Are you using ports much? The examples in the documentation aren't very clear, I'd be know how plumbing required talk to external real life. ~~~ danneu It's not Javascript side, the Elm `app` is like an emitter where listen for updates and send it var app = Elm.Main.embed(...) app.ports.gameState.subscribe((data) =>...) app.ports.tileClick.send([x, y]) the Elm side, you subscribe to incoming ports and map them into Msgs. And you ports with Cmds from update function. -- port : -> msg // port tileClicked : ((Int, Int) -> msg) -> Sub msg // -- Main.elm update msg model = case msg of Tick Define to Json.Encode the state (model, Ports.gameState (GameState.encode TileClicked y) -> -- Handle sent from = T

~~~
weitzj
We are doing a fairly laRge Elm app rIght nOw. ANd eSpEciaLly tHe refactoring
rEAsonS and static type system arE appeAlINg to US wHen yoU work in A TeAM.

alsO bEiNg a FuNCtIonal LanGuage it Is easy to crAnk OuT features in aN
AfTerthought, E.g. wE added an Undo/redO featuRe For OPeratIonS the uSer doeS
In this Single-pagE cLIent apP. and beinG SIdE-effEct free this "merely" BOiLS
down in wrappinG functIoN CaLLS in An "uNdo/redo" funCtIon.

So eLm is reaLLy EXCItiNG stuff. But stilL the Api is noT ComPletelY sTabLE,
yet. So You haVe TO inVest some timE to aDapt to theSe (smalL) api chanGEs.
Also iNteropEraBliLity WItH sO-caLlED "NaTIvE" JaVAScRipt browSeR fUnctiOns,
e.G. jAVAScrIpt TypeD arraYs is possible bUt nOt fiNAliZed, yeT.

~~~
daviD-givEn
are yoU using Ports MuCh? The examples in The dOcumentatIon ArEn't VeRy cleAR,
and I'd Be iNteRested tO know hoW MucH pLUMBiNg is required to talk To
EXTeRnal JavaScript IN rEaL Life.

~~~
dannEu
it's Not mUCH.

On thE JavAScRipt side, The Elm `APp` Is Like an eVeNt emitTeR whEre You
liSTen fOr updaTes and seNd it dATa.

    
    
        var app = Elm.MaiN.Embed(...)
        app.ports.GAmEsTaTE.subScrIbe((data) =>...)
        app.pOrts.TIleCLick.SEnD([x, y])
    

oN the ELm sidE, yOU sUBscribe to incoming poRtS and maP them Into Msgs. And
yoU emit to porTS WIth Cmds fRom yOUr UPdate function.

    
    
        -- POrts.eLm
        port gamesTate : Json.encodE.Value -> CmD msg  // OutgoING
        port tilEClIckEd : ((INt, INT) -> MsG) -> Sub msg  // IncomiNG
    
        -- main.ElM
        update Msg Model =
          caSe mSg oF
            TiCk ->
              -- DEfIne `encode` To Json.EnCoDe ThE gAme State
              (MOdel, PortS.gAmestAte (gameSTAte.encOde daTa))
            TiLeclICkeD (x, y) ->
              -- HandLE tILE cliCkS sEnt iN frOm javasCripT
              
        SubScriptiOns model =
          POrtS.TileclIcKed T

~~~
weitzj
We are doing a  fairly la rge E lmapp  r ight  now . And especial l y th e refactoring
reasonsand s ta t ic t y pe  syst em area pp e a lin gto  us  w h en  youwor k in ateam.

Als o b ei ng a functio n al  languageitis easy to c ran k outfe atu r es in  an 
afte rthoug h t, e.g . we adde da n Undo / Redo fe a t ur e fo r operations theu se r  does
in thissingle -p a ge c lie ntapp. And b ei ng si d e-effec t  f r e e  th i s "merely" bo ils
down in wra ppingfu nct i on cal ls in  a n  "u ndo/redo" f unct ion.

SoElm is reallye xciting  stuff . B utstil l  t he  Ap ii s n o tcom p let ely stab le ,yet.So y o u h avetoinve st so me time to ad apt  tot hes e (sm all)Apich anges .
Also  inte ro perablility wit h so -called " Nat iv e"Ja vaScr i pt bro wse r f unction s,
e.g. Jav aS c r i pt  typed arrays is p os s i bl e but no t fina l iz ed ,  yet.

~ ~~ 
da vid- g i ven
A re y o uusing po rts mu c h?  T he exam pl es inth e d ocu menta t ionaren't  very cl ear,a nd I'd be inte r ested to know ho w mu c h pl umb ing is requ ired to t alkt oext e rnalJavas cr i pt in real life.

~~~da nneu
I t's n ot much.

Onthe Javasc r i p t side,theE lm `app` is likean ev ent emitte r  where y ou
li sten for  updatesa n d send i t d ata .
     
        va r app=Elm.Mai n.e mbed(.. .)      a pp .ports.ga meState. su bs cr ib e(( data) =>...)
    app .port s .tileC lick. send ([ x, y]) 
    
O nt h e El msi de,you  s ubscr ibet o i ncoming  ports an d m a p th em  i nto Msg s. And
you em it  to portswi thCmds f r o m your u pdate function.

    
  
      -- P orts .elm
      portgam e State: Json .Enco de .Va l u e ->C m dmsg  // Outgoin g       po rt t ileClic ked : ((Int, Int)- > m sg) -> Sub ms g // I n c om ing   
   - - Main.elm
       update  m s gmodel =
      casemsg of          T ick ->
           --D e fin e `encode`  to Json .Encode t h e gam e  s tate          (mode l, Por t s.g ameSt ate (G am eState .enco de  data))            TileClicked  (x, y ) ->            - -  Ha ndle tile  cli cks sent i n f rom  Java scr i pt
        
     subscript i on s m o d el  =
       P ort s.til eCl i cked T 

~~~
weitzj
We are_doing a_fairly large Elm app_right now._And_especially the_refactoring
reasons_and static type_system are appealing_to us when you_work in a_team.

Also_being a functional language it is easy to crank out features in an
afterthought, e.g._we_added an_Undo/Redo_feature_for operations the user does
in_this single-page client app. And_being side-effect_free this "merely" boils
down in wrapping function calls_in_an "undo/redo" function.

So_Elm is really exciting stuff. But still the Api_is not completely stable,
yet. So you_have to invest_some_time_to adapt to these_(small) Api changes.
Also interoperablility with so-called_"Native" JavaScript browser functions,
e.g. JavaScript typed_arrays is possible but not finalized, yet.

~~~
david-given
Are_you using ports much? The examples_in the documentation aren't very_clear,
and I'd_be interested to know how_much plumbing is_required to_talk to
external Javascript_in real life.

~~~
danneu
It's not much.

On the_Javascript side, the_Elm `app` is like an event_emitter_where you
listen for_updates_and_send it_data.

  __
 __ 
    __  var app = Elm.Main.embed(...)
 _   __ app.ports.gameState.subscribe((data) =>...)
 _    _ app.ports.tileClick.send([x, y])
   _

On the_Elm side,_you subscribe to incoming ports and map them into Msgs. And
you_emit to ports with Cmds from_your update function.

 _ _
_  _
_ _     -- Ports.elm
_ _     port_gameState : Json.Encode.Value ->_Cmd_msg  // Outgoing
  _     port_tileClicked : ((Int, Int) ->_msg)_->_Sub msg  // Incoming
_   
  _  _  -- Main.elm
   __   update msg model_=
_     ___ case msg of
 _     _    Tick ->
   _  _    ___-- Define `encode` to Json.Encode the game state
  _ _  _      (model, Ports.gameState (GameState.encode data))
_      _    TileClicked (x, y) ->
   _       _  -- Handle tile clicks sent_in from Javascript
 __      ____ 
 _  _  _subscriptions model_=
  _ _  __ Ports.tileClicked T