[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] 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.


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.


[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.