[elm-discuss] undefined: actually I have expected to never face undefined again with elm

2016-07-18 Thread Andreas Kobler
Hi all

Just started to play around with elm and very eager to get more fluid. I 
picked a silly POC scenario of a rule composer: basically you have regex 
rules and want to edit/test them in a form. When applying a regex and 
showing the replace output in an input field, I face an "undefined". Below 
you see the isolated part forcing my observation while applying the rule 
directly in init.

Unfortunately I could really not trace down to the root of this happening. 
Is somebody able to tell me:
- What I am doing wrong? Why does there an "undefined" appear? (wenn 
executing my own "replace" function in the REPL it works fine as expected)
- How do you guys debug such behaviour?

Here my silly example:


module RuleTest exposing (..)


import Html.App
import Html exposing (..)
import Html.Attributes exposing (..)
import Regex


main : Platform.Program Basics.Never
main =
  Html.App.program
{ init = init
, view = viewRuleTest
, update = update
, subscriptions = \_ -> Sub.none
}


type alias Rule = 
  { regex : String
  , substitution : String
  }


type alias RuleTest = 
  { rule : Rule
  , input : String
  , output : String
  , matched : Bool
  }


type Msg 
  = StartTest String




-- init
init : (RuleTest, Cmd Msg)
init =
  ( apply "reg1" (Rule "reg1" "sub1")
, Cmd.none
  )


-- update
update : Msg -> RuleTest -> (RuleTest, Cmd Msg)
update msg ruleTest =
  case msg of


StartTest input ->
  ( apply input ruleTest.rule, Cmd.none )




apply : String -> Rule -> RuleTest
apply input rule =
  let 
output = replace rule.regex rule.substitute input
matched = input /= output
rule = rule
  in
RuleTest rule input output True


replace : String -> String -> String -> String
replace regex substitute input =
  Regex.replace Regex.All (Regex.regex regex) (\_ -> substitute) input


viewRuleTest : RuleTest -> Html Msg
viewRuleTest ruleTest =
  div []
[ label [] [ text "Pattern" ]
, input [ Html.Attributes.value ruleTest.rule.regex, disabled True ] []
, label [] [ text "Substitution" ]
, input [ Html.Attributes.value ruleTest.rule.substitution, disabled 
True  ] []
, label [] [ text "Input" ]
, input [ Html.Attributes.value ruleTest.input, disabled True  ] []
, label [] [ text "Output" ]
, input [ Html.Attributes.value ruleTest.output, disabled True  ] []
, label [] [ text "matched" ]
, input [ type' "checkbox", checked ruleTest.matched ] []
]


Environment: 
elm repl --version
0.17.1
OSX 10.11.3

{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git";,
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.1 <= v < 5.0.0",
"elm-lang/html": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.17.1 <= v < 0.18.0"
}


Thanks for any advice!

Best, Andi


-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Scrolling to bottom of div

2016-07-18 Thread Wayne Choi
I want to scroll down to the bottom of a div for, what else, a chat app. 
Right now I'm using element.scrollTop = element.scrollHeight  and it works 
fine with just javascript and html. Once I port the div to Elm, however, 
the function doesn't scroll all the way down. Am I missing something with 
how javascript interacts with the virtual dom? Is there an alternative 
solution? 

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: html formatting words in string

2016-07-18 Thread Wayne Choi
Yeah, it took me a bit to get my head around it but I really appreciate how 
elegant the solution is. 

On Sunday, July 17, 2016 at 7:32:59 PM UTC-7, Max Goldstein wrote:
>
> I'll jump in here and say that this is one of the things I really like 
> about Elm views. Instead of needing to learn some crippled templating 
> language (handlebars, JSX) you can just use all the normal list functions.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-18 Thread Evan
Both Max and Aaron PS suggested using extensible records for this scenario, 
but I don't think that is the right way to go. It is particularly tempting 
for folks who want Elm to just work like an OO language, but it isn't like 
that. I think Tessa put it very nicely in her post 
: 
extensible 
records are for making functions flexible, not for modeling your data. I 
highly recommend OP and the folks who suggested extensible records read 
that post!

I believe Tessa's 
 and 
Aaron Vonderhaar's advice will get you to better code that is easier to 
understand and refactor.

On Sunday, July 17, 2016 at 6:40:52 PM UTC-7, Max Goldstein wrote:
>
> Aaron's solution is a good one, but since customers and employees are both 
> people, you may want:
>
> type alias Person a =
> { a | name : String
> , address : String
> }
>
> type alias Employee =
> Person { department : String }
>
> type alias Customer =
> Person { itemsPurchased : Int }
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-18 Thread Leroy Campbell
It may help to watch this talk on modeling from a functional programming 
perspective (features F#, but applicable to Elm since they both are 
ML-based):

https://vimeo.com/162036084

On Sunday, July 17, 2016 at 7:06:32 PM UTC-4, Leonardo Sá wrote:
>
> Short question:
>
> What is the best way to create relationships between my types so it is 
> easy to access data present in both types?
>
> Long question:
>
> Suppose I have the following types:
>
> type alias Person =
>   { name : String
>   , address : String
>   , personType : PersonType 
>   }
>
> type alias Employee =
>   { department : String }
>
> type alias Customer =
>   { itemsPurchased : Int }
>
> type PersonType = EmployeeType Employee | CustomerType Customer
>
> Then I think it's not straight forward to write a function that retrieves 
> me the department and name for an employee:
>
> nameAndDepartment : Person -> (String, String)
>
> It seems to me this function would be a Maybe (String, String) and return 
> Nothing if the Person is not an Employee. But in that case, I am relying on 
> the runtime to type check things for me, which tells me there is probably a 
> better way to structure this.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Port Error

2016-07-18 Thread Leroy Campbell
I recreated your example without issue, so I wonder if there is another 
problem. Here's a fork of your gist:

https://gist.github.com/artisonian/11e93321cd7fd108142115269cbeafe7

On Monday, July 18, 2016 at 4:40:06 AM UTC-4, Zachary Kessin wrote:
>
> I am having a strange problem with ports, I am trying to send a list of 
> data through the port (see gist) and I it is giving me a runtime error. 
>
> Actually it seems to have nothing to do with the data, as I am trying to 
> send a string through a different port in the same file and getting the 
> same error. 
>
> Some ports in other files work ok
>
> https://gist.github.com/zkessin/e5b61e80f2d280e5496f60a8e42f0c79 
> 
>
> -- 
> Zach Kessin
> Twitter: @zkessin 
> Skype: zachkessin
> ᐧ
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] What is the Elm-way to update a nested record field?

2016-07-18 Thread Peter Damoc
If you talk about explicitly updating each level then yes, that's still the
best approach.
You break your models into components and update each component as per Elm
Architecture.

If you talk about Focus, then no, I have not seen that really used.

you could do update functions like this:

updateLeftX x ({left} as model) =
   { model | left = {left | x = x} }

but it is better to have something like

updateLeftX x model =
{ model | left = Point.updateX x model.left}



On Mon, Jul 18, 2016 at 8:40 PM, Jesse Schoch  wrote:

> Is this still the best way to deal with nested record updates?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] What is the Elm-way to update a nested record field?

2016-07-18 Thread Jesse Schoch
Is this still the best way to deal with nested record updates?

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Port Error

2016-07-18 Thread Nick Hollon
It is not clear how onEffects.js is related to your elm program. Could you give 
us a self-contained example?

> On Jul 18, 2016, at 1:40 AM, Zachary Kessin  wrote:
> 
> I am having a strange problem with ports, I am trying to send a list of data 
> through the port (see gist) and I it is giving me a runtime error. 
> 
> Actually it seems to have nothing to do with the data, as I am trying to send 
> a string through a different port in the same file and getting the same 
> error. 
> 
> Some ports in other files work ok
> 
> https://gist.github.com/zkessin/e5b61e80f2d280e5496f60a8e42f0c79
> 
> -- 
> Zach Kessin
> Twitter: @zkessin
> Skype: zachkessin
> ᐧ
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Svg.image not showing when embedded inside HTML

2016-07-18 Thread Peter Damoc
Wow, changing

attribute "xlink:href" imgData

to

xlinkHref imgData

solved the issue. Which was a little bit weird because the output code
looks identical.

With this occasion I also found out about attributeNS, which might come in
hand. ;)

Thank you Iwan!




On Mon, Jul 18, 2016 at 4:43 PM, Iwan Birrer  wrote:

> Hi Peter,
>
> Have you got a specific reason to use VirtualDom directly? If not, here is
> a version that should work, which is not using VirtualDom:
>
> https://gist.github.com/ibirrer/1ab87a2e9b0acad6976a06a3a8a76bff
>
>
>
> Am Montag, 18. Juli 2016 13:18:10 UTC+2 schrieb Peter Damoc:
>>
>> Hello kind people,
>>
>> I've been struggling with an issue and maybe one of you has an insight on
>> what else could I try.
>>
>> Here is the SSCCE:
>> https://gist.github.com/pdamoc/53a312e7bb3d08b256a2afb3a584661f
>>
>> *The problem:*
>> I try to display an image embedded as base64 inside a SVG (the final
>> purpose is to print it.)
>> The image does not show when I try to display the resulting SVG.
>>
>> The strange thing is that when I send the contents of the "output" div to
>> a new window, the image shows. If I manually copy the resulting html (via
>> the dev tools) into a plain html file, again, the image shows.
>>
>> I've tried it on Chrome, Firefox and Safari and the behavior is
>> consistent.
>>
>> I've validated the output html that elm-make creates and it is 100%
>> valid.
>>
>> I've even tried to put the resulting SVG into an iframe but the iframe
>> came out blank.
>>
>> What else can I try?
>>
>> Thank you in advance.
>>
>> --
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Trying to understand the community overlap between Elm and Elixir

2016-07-18 Thread Rex van der Spuy


>
> Can someone help clarify why Elixir is appealing to Elm developers 
> specifically (as opposed to Elixir being appealing on its own merits)?
>

Actually, Elm is appealing to Elixir developers, not the other way around 
;) 
A lot of the talk you see around Elixer in Elm's discussion forums seems to 
be from Elixer developers who have found Elm to be a useful front-end 
solution.
Elm on the backend is ultimately the way to go.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Source Maps? /was Elm Dev Tools

2016-07-18 Thread eric
Waking up an old discussion here ...

I'm new to Elm and considering it for a new project.

I was surprised / disappointed to learn that code coverage is not yet 
supported in Elm. Has there been any further consideration of support for 
code coverage in Elm? The lack of coverage is not an absolute show-stopper 
for me, but my experience with other languages has taught me to be far more 
comfortable with data model code that is thoroughly tested.

(Like others in this thread, I am less concerned with unit test coverage 
for view code.)

-Eric


On Tuesday, October 20, 2015 at 2:37:26 PM UTC-7, Igor Tur wrote:
>
> I see it this way:
>
> - Source maps are required for Code Coverage (example 
> https://www.npmjs.com/package/istanbul-coverage-source-map)
> - Code Coverage is required for integration into any enterprise 
> environment (it doesn't really open the door, but absence may close the 
> door)
>
> Also something like elmLint would be required.
>
> And then integration with SonarCube (or similar) systems - for source code 
> analysis, complexity and overall control of source code changes.
>
> Thank you,
> Igor
>
>
> On Wednesday, July 1, 2015 at 6:38:52 PM UTC-7, Evan wrote:
>
>> Based on Texas' post 
>> , I am 
>> really curious to hear folks thoughts on source maps for my personal 
>> planning and prioritization!
>>
>> Last time source maps came up, I was choosing between "fix the type 
>> checker" and "do source maps". Fixing inference in 0.9 (or whatever) was a 
>> really really big deal and I think it was the right choice, but we never 
>> revisited the source maps. It also does not fit into my workflow (which is 
>> very atypical) so it's not something that I *personally* miss.
>>
>> So essentially, how would source maps help you?
>>
>>- Do you have times when you want them?
>>- Do you think it has a marketing / perception benefit that'd make it 
>>worth it no matter what?
>>
>> If you aren't a regular poster, I'm extra interested to hear your 
>> perspective! I need to collect data and perspectives on this to prioritize 
>> it.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Port Error

2016-07-18 Thread Duane Johnson
Where is `subs` coming from? I see it used in the onEffects function, but I
don't see its definition.

On Mon, Jul 18, 2016 at 2:40 AM, Zachary Kessin  wrote:

> I am having a strange problem with ports, I am trying to send a list of
> data through the port (see gist) and I it is giving me a runtime error.
>
> Actually it seems to have nothing to do with the data, as I am trying to
> send a string through a different port in the same file and getting the
> same error.
>
> Some ports in other files work ok
>
> https://gist.github.com/zkessin/e5b61e80f2d280e5496f60a8e42f0c79
>
> --
> Zach Kessin
> Twitter: @zkessin 
> Skype: zachkessin
> ᐧ
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Svg.image not showing when embedded inside HTML

2016-07-18 Thread Iwan Birrer
Hi Peter,

Have you got a specific reason to use VirtualDom directly? If not, here is 
a version that should work, which is not using VirtualDom:

https://gist.github.com/ibirrer/1ab87a2e9b0acad6976a06a3a8a76bff



Am Montag, 18. Juli 2016 13:18:10 UTC+2 schrieb Peter Damoc:
>
> Hello kind people, 
>
> I've been struggling with an issue and maybe one of you has an insight on 
> what else could I try.
>
> Here is the SSCCE: 
> https://gist.github.com/pdamoc/53a312e7bb3d08b256a2afb3a584661f
>
> *The problem:*
> I try to display an image embedded as base64 inside a SVG (the final 
> purpose is to print it.)
> The image does not show when I try to display the resulting SVG. 
>
> The strange thing is that when I send the contents of the "output" div to 
> a new window, the image shows. If I manually copy the resulting html (via 
> the dev tools) into a plain html file, again, the image shows. 
>
> I've tried it on Chrome, Firefox and Safari and the behavior is 
> consistent. 
>
> I've validated the output html that elm-make creates and it is 100% valid. 
>
> I've even tried to put the resulting SVG into an iframe but the iframe 
> came out blank. 
>
> What else can I try? 
>
> Thank you in advance. 
>
> -- 
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Svg.image not showing when embedded inside HTML

2016-07-18 Thread Peter Damoc
Hello kind people,

I've been struggling with an issue and maybe one of you has an insight on
what else could I try.

Here is the SSCCE:
https://gist.github.com/pdamoc/53a312e7bb3d08b256a2afb3a584661f

*The problem:*
I try to display an image embedded as base64 inside a SVG (the final
purpose is to print it.)
The image does not show when I try to display the resulting SVG.

The strange thing is that when I send the contents of the "output" div to a
new window, the image shows. If I manually copy the resulting html (via the
dev tools) into a plain html file, again, the image shows.

I've tried it on Chrome, Firefox and Safari and the behavior is consistent.

I've validated the output html that elm-make creates and it is 100% valid.

I've even tried to put the resulting SVG into an iframe but the iframe came
out blank.

What else can I try?

Thank you in advance.

-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Trying to understand the community overlap between Elm and Elixir

2016-07-18 Thread Zachary Kessin
I have been using Erlang (but not Elixir) for a bunch of years now and
mostly find it is a great toolset for getting stuff done. Elm was a nice
find as it (mostly) saves you from the crap that is Javascript. I have
found that they work well together

Zach
ᐧ

On Sun, Jul 17, 2016 at 5:07 PM, John Orford  wrote:

> My feeling is that their conception was at about the same time and had
> broadly the same goals.
>
> I.e. make complicated programs sane.
>
> On top of that, I see the adopters being similar.
>
> Those who are looking for a better way and open to new ideas.
>
> I agree with you.
>
> Elm has many nice features that Elixir does not. Until we can run Elm on
> the BEAM Elixir is probably the way to go server-side : )
>
> On Sun, 17 Jul 2016 at 15:56 Charlie Koster  wrote:
>
>> For those of you who learned Elm before learning Elixir can you describe
>> the appeal of Elixir from an Elm dev standpoint? I'm having trouble finding
>> appealing similarities between the two.
>>
>> While there are some similarities to be found, Elixir doesn't appear to
>> have a lot of what makes Elm great. For example, Elixir is dynamically
>> typed, uses impure functions, has try-catch, and has other language
>> constructs that remind me why I prefer Elm over Javascript.
>>
>> Can someone help clarify why Elixir is appealing to Elm developers
>> specifically (as opposed to Elixir being appealing on its own merits)?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Zach Kessin
Your CRM Link

Twitter: @zkessin 
Skype: zachkessin

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Port Error

2016-07-18 Thread Zachary Kessin
I am having a strange problem with ports, I am trying to send a list of
data through the port (see gist) and I it is giving me a runtime error.

Actually it seems to have nothing to do with the data, as I am trying to
send a string through a different port in the same file and getting the
same error.

Some ports in other files work ok

https://gist.github.com/zkessin/e5b61e80f2d280e5496f60a8e42f0c79

-- 
Zach Kessin
Twitter: @zkessin 
Skype: zachkessin
ᐧ

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.