[elm-discuss] Re: Higher-order functions with a function using an extensible record?

2017-10-04 Thread Ilias Van Peer
mapNamed : (Named a -> b) -> Element -> b

In that line, you say that I can pass in a function that works on `Named a`, 
where `a` isn't bound to anything. So if I were to write a function `foo : 
Named { iAlsoNeedAnInt : Int } -> Int`, I could pass that to that `mapNamed`. 
However `Element` contains a very *specific* type of `Named a` - it is a `Named 
{}`.

So one thing you could do is changing the annotation to say `mapNamed : 
(Named {} -> b) -> Element -> b`. Note that this would fall apart as soon 
as the different values in `Element` actually have different types.

Note that this isn't unique to extensible records, or even records at all. 
Say you wanted to allow passing `identity` in. You could try `mapNamed : (a 
-> b) -> Element -> Element`, but that also wouldn't work.. Because I could 
pass in `(\x -> x * 7)` which has type `number -> number`, which is valid 
according to the `a -> a` shape.

I hope this clarifies things a little?

Op woensdag 4 oktober 2017 16:19:45 UTC+2 schreef Rémi Lefèvre:
>
> Hi,
>
> Does anyone know if there is a way to use higher-order functions with a 
> function using an extensible record?
>
> When I try to build this code:
>
> type alias Named a =
>{ a | name : Maybe String }
>
> getName : Named a -> Maybe String
> getName { name } =
>name
>
> type Element
>= AnElement { name : Maybe String }
>| AnotherElement { name : Maybe String }
>
> mapNamed : (Named a -> b) -> Element -> b
> mapNamed func element =
>case element of
>  AnElement e ->
> func e
>
>  AnotherElement e ->
> func e
>
> getElementName : Element -> Maybe String
> getElementName e =
>mapNamed getName e
>
>
>
> I get the following error:
>
> Detected errors in 1 module. -- TYPE MISMATCH 
> --- Types.elm The argument to function 
> `func` is causing a mismatch. 13| func e ^ Function `func` is expecting 
> the argument to be: Named a But it is: { name : Maybe String } Hint: Your 
> type annotation uses type variable `a` which means any type of value can 
> flow through. Your code is saying it CANNOT be anything though! Maybe 
> change your type annotation to be more specific? Maybe the code has a 
> problem? More at: <
> https://github.com/elm-lang/elm-compiler/blob/0.18.0/hints/type-annotations.md>
>  
>
>
>
> I struggle to understand why this does not work whereas replacing *func* 
> by *getName* satisfies the compiler:
>
> getElementName : Element -> Maybe String
> getElementName element =
>   case element of
>   AnElement e ->
>   getName e
>
>   AnotherElement e ->
>   getName e
>
>
> Any idea ?
>
> Thank you and sorry if this has been already discussed, I did not find 
> anything.
>
>
>
>

-- 
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: Issues with drag & drop (also reproducible in drag example on elm website)

2017-10-04 Thread Leonardo Farroco
I'm currently working in an application with heavy drag'n drop logic, so 
this topic caught my attention in the past days.

One question that comes to mind, is this a problem that is exclusive to 
> Elm? Or do all javascript applications potentially suffer from it?


By looking at this issue suspecting on how the browser handles drag 
events,  I was able to find this answer:
https://stackoverflow.com/questions/5429827/how-can-i-prevent-text-element-selection-with-cursor-drag

Dragging an element that has selectable text is a conflicting behavior 
(from the browser's point of view), so we need to be explicit at what 
results we want - in this case, not let the text being selected when the 
mouse in pressed in the parent.

Following the advice from the SO answer, we are able to use 
e.preventDefault() with Elm's onWithOptions. In the Drag Example, we just 
need to replace the onMouseDown function with:

onMouseDown : Attribute Msg
onMouseDown =
  onWithOptions
  "mousedown"
  { stopPropagation = False
  , preventDefault = True }
  (Decode.map DragStart Mouse.position)


On Monday, September 25, 2017 at 6:45:33 AM UTC-3, Rupert Smith wrote:
>
>
> On Friday, September 15, 2017 at 12:27:27 PM UTC+1, Jan Hrček wrote:
>>
>> I've been figthing with the following drag and drop issue: when 
>> performing multiple drag & drop operations in rapid succession it sometimes 
>> happes that drag is in progress, even though my mouse key is up.
>>
>
> Also happens in MS Edge.
>
> I suspect the following is happening: Mouse goes down on the drag-able 
> item, but you are also moving the pointer at the same time. Elm gets the 
> mouse down event and begins the drag. Meanwhile you have moved the pointer 
> outside of the drag-able item, and release the button outside of it. As 
> this event is not on the item, it does not reported to Elm as a mouse up 
> event.
>
> I also see a very similar issue in my code, where I have a piece of 
> editable content that I want to highlight when the mouse goes over it to 
> show that it can be clicked and edited. Sometimes it fails to pick up the 
> mouse out event and remains highlighted when it should not. I have not 
> really explored the issue in depth, but I need to, so I am interested in 
> how to solve this.
>
> One question that comes to mind, is this a problem that is exclusive to 
> Elm? Or do all javascript applications potentially suffer from it? Is it 
> just a question of thinking more clearly about where in the DOM structure 
> you need to pick up the mouse up/down or in/out events?
>

-- 
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] WebRTC and Elm

2017-10-04 Thread Anil Wadghule
Hi,

We are building a product around WebRTC video chat. I am thinking of 
choosing Elm as a language to build our web front end.

I am new to Elm and haven't yet explored Elm ports. 

Can someone suggest what is the scene of Elm with something like WebRTC? 
How easy is to write ports of Native JS APIs like WebRTC etc.

Would appreciate your detailed reply.

Thank you,
Anil

-- 
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: WebRTC and Elm

2017-10-04 Thread Anil Wadghule
Hi Mitch

Were you able to create writeup? 

I am about to start using Elm with WebRTC.

Thanks,
Anil

On Monday, 8 August 2016 19:21:37 UTC+5:30, Berry Groenendijk wrote:
>
> Hi Mitch,
>
> I am very much interested in your writeup. I am writing a prototype for an 
> app. I am just building the front-end, the UI in Elm. No back-end. And I 
> thought... wouldn't it be nice to share the in-memory data between browsers 
> that have the app open. So, I looked at WebRTC. But, then I found Orbit-db (
> https://github.com/haadcode/orbit-db). A distributed peer-to-peer 
> database build on top of IPFS. It is still very beta software. I got some 
> basic functionality working using ports. Unfortunately, the database does 
> not seem to sync between clients... But, I like the idea. Building Elm apps 
> with storage in a distributed cloud.
>
> So, I am looking forward to your writeup!
>
> Berry
>
> Op maandag 8 augustus 2016 14:51:44 UTC+2 schreef White Jack:
>>
>> Hi Mitch,
>> thanks a lot for sharing. Have you created port of some existing JS 
>> library or created ELM implementation from scratch?
>>
>> On Sunday, 15 March 2015 18:15:08 UTC-4, Mitch Spradlin wrote:
>>>
>>> Hello everyone,
>>>
>>> I'm fairly new to Elm and as a part of the learning process I wrote an 
>>> Elm application that uses WebRTC to connect peers to each other to create a 
>>> distributed network that allows users to chat with each other. After 
>>> showing it to some people, they encouraged me to create a writeup about how 
>>> WebRTC and Elm can interoperate. However, not having written much about 
>>> software other than documentation, I would appreciate any thoughts on what 
>>> subtopics would be interesting to discuss and which ones are not as 
>>> interesting to cover.
>>>
>>> The writeup probably wouldn't be super long and would focus on the 
>>> current state of using WebRTC in and Elm application. After a broad-strokes 
>>> summary of WebRTC and how it can be brought together with Elm using ports, 
>>> I would explore some possible patterns that come from using ports to have 
>>> the kind of one-way effects characteristic of this use case. I would then 
>>> talk about difficulties that are encountered in this setup and finish with 
>>> how promises (soon to be renamed commands?) will likely change things such 
>>> that writing the Elm side of things in this context will be much easier.
>>>
>>> Again, I appreciate any thoughts y'all might have!
>>>
>>> Thank you,
>>> Mitch
>>>
>>

-- 
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: Hiring Elm developers at Prezi

2017-10-04 Thread Ketan Shukla
I'm seeing this post after 3 years lol ... is it too late to apply? I would 
really like to move on a project where I'm not directly coding HTML CSS or 
JS. When I saw how you can use Elm to replace these, I took interest in the 
language. 

On Wednesday, January 22, 2014 at 10:04:05 AM UTC-8, Laszlo Pandy wrote:
>
> TL;DR   Now is the time to join Prezi if you want to be part of the first 
> team to release Elm code to 30+ million users.
>
> Less than a year ago, Prezi hired Evan to work on Elm so that one day in 
> the future we would have a type-safe way to write web applications without 
> the pain of event listeners. I thought it would take more than a year, but 
> 8 months later we have all the pieces in place to start releasing projects 
> written in Elm.
>
> We know that we won’t ever be able to write all of Prezi in Elm even if we 
> wanted to (we don’t). But since our application is always getting bigger, 
> we started using a component model for our JavaScript code. This inspired 
> Evan to release ports in 0.11, and we already implemented a prototype 
> plugin for Prezi’s build system to make it easy to use an Elm component 
> from JavaScript in a familiar way.
>
> Now we are looking for a clever developer to make Elm the language of 
> choice for new JavaScript components at Prezi. This is someone who likes 
> functional programming but loves making graphical web apps even more.
>
> You will:
>
>- 
>
>Write UI components in Elm
>- 
>
>Work alongside Evan to define new libraries and Elm graphics APIs
>- 
>
>Build reusable UI widgets in Elm (ie. buttons, menus, sidebars, etc.)
>- 
>
>Teach designers how to update styles and shapes in Elm code
>- 
>
>Improve our Gradle build tools to make building and integrating Elm 
>components easier
>- 
>
>Use your knowledge of functional programming to write clean TypeScript 
>code when something cannot be done with Elm
>- 
>
>Convince other people in Prezi how comfortable it is to develop for 
>the web in Elm
>- 
>
>Speak at meetups and make Elm known outside the company
>
>
> Prezi is a polyglot company. Across our frontend and backend teams, we use 
> at least 13 different programming languages. In a single team you can 
> expect to see 2 or 3 languages used for different tasks. We want you to 
> help us make Elm one of the most important ones.
>
>
> If you are interested, please email me directly or apply to the 
> Compile-to-JS position on our jobs page:
> https://prezi.com/jobs/oiRxXfwn/
>

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