Re: [elm-discuss] Re: Again: which editor do you like best for Elm?

2017-02-06 Thread GordonBGood
On Tuesday, 7 February 2017 03:22:53 UTC+7, Dave Rapin wrote:
>
> MS bought Xamarin, who made Mono (http://www.mono-project.com/), which 
> allows you to target Linux, iOS, Android w/ .NET. They seem to be 
> embracing Linux for the last couple of years. Hell you even get a 
> Linux within Windows 10 now if you opt in 
> (https://github.com/ethanhs/WSL-Programs). 
>
> On Mon, Feb 6, 2017 at 3:14 PM, 'Rupert Smith' via Elm Discuss 
>  wrote: 
> > On Saturday, February 4, 2017 at 7:35:37 AM UTC, GordonBGood wrote: 
> >> 
> >> I'm using Visual Studio Code with the Elm plug-in.  Works pretty well. 
> > 
> > 
> > BTW, does the fact that Microsoft have VS Code for Linux mean that 
> Microsoft 
> > now fully supports .Net on Linux too? This is a development I haven't 
> really 
> > kept up with, not being a windows user. 
>

It's more than as @Dave has said:  MS now offers DotNet Core which is open 
source and available across all major platforms, and I suppose VS Code fits 
under that initiative.  This looks to be a complete re-write of the 
mono-project to make it more compatible and better performance wise, as 
well as being more generally compatible with full DotNet.

So more than just having project-mono as a side project, it is now fully 
integrated into full Visual Studio, etc.

MS has been moving this way for quite some time, with F# having been an 
open source project for quite some time.

Running "Linux within Windows" is a bit of an exaggeration, but yes, one 
can opt in to running a bash shell inside windows under a version of UBuntu.

As I said, VS Code works pretty well with the Elm plug-in, and there are 
lots of other third party plug-ins for markdown, HTML, etc.

-- 
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: Refactoring application to extract model, update and some actions

2017-02-06 Thread 'Rupert Smith' via Elm Discuss
On Saturday, February 4, 2017 at 11:29:44 PM UTC, Pierre-Henri Trivier 
wrote:
>
> To anyone reading, I might have solved it myself : 
> https://phtrivier.github.io/2017/02/05/elm-tail-end-part-5.html
>

I think it is good that the Period module that you pulled out is completely 
hidden behind Tailend. So Main is just importing Tailend, it is not ending 
up having to import Period and Tailend. This is my objection to the 
Type/State/View pattern - it basically means you import 3 things when it 
would be neater to just import 1.

One thing I have found helpful when trying to refactor into modules is to 
avoid importing and exposing using (..). I now always explicitly expose 
what I want the public interface of a module to be, even if it is never 
going to be a published library. I find this very a helpful design tool 
that gets me to focus on what the purpose and main responsibilities of a 
module are and to avoid binding other modules to internals that they should 
not see.

Refactoring to improve the modular design is an aspect of Elm that 
interests me at the moment - mostly because I am still getting to grips 
with it myself. My suggestions may not be optimal, please don't take them 
as criticism, just another set of ideas to share as we learn together.

-- 
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: Refactoring application to extract model, update and some actions

2017-02-06 Thread 'Rupert Smith' via Elm Discuss
On Sunday, February 5, 2017 at 9:37:54 PM UTC, Keith Lazuka wrote:
>
> One question you might or might not have asked yourself is whether the 
> encapsulation is worth it. Why should the `Period` state be hidden with an 
> opaque type? If you're writing a library, then, yes, it makes total sense 
> so that you can avoid having to make major version bumps as the library 
> evolves. But if this is an application-specific component which will only 
> ever be used *within* this project, then you might not need the 
> encapsulation.
>

I have to agree. I have split out pieces of re-usable view code and made 
them re-usable by passing in 'tagger's for tagging the events, but I have 
only done this for bits of view that are being re-used in multiple 
situations - a set of 'ok/cancel' buttons might be a reasonable example.

What I look for first is things that are not bound to the main Type of a 
module, and that a module does not need to expose. Recently I have been 
using some animations with elm-style-animation. I found that the animation 
styles and easings did not depend on the Model type for the module I was 
working with, and also are completely internal to it. So they were the 
first thing I moved into a separate file, purely to try and keep the main 
file shorter.

-- 
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: Again: which editor do you like best for Elm?

2017-02-06 Thread Dave Rapin
MS bought Xamarin, who made Mono (http://www.mono-project.com/), which
allows you to target Linux, iOS, Android w/ .NET. They seem to be
embracing Linux for the last couple of years. Hell you even get a
Linux within Windows 10 now if you opt in
(https://github.com/ethanhs/WSL-Programs).

On Mon, Feb 6, 2017 at 3:14 PM, 'Rupert Smith' via Elm Discuss
 wrote:
> On Saturday, February 4, 2017 at 7:35:37 AM UTC, GordonBGood wrote:
>>
>> I'm using Visual Studio Code with the Elm plug-in.  Works pretty well.
>
>
> BTW, does the fact that Microsoft have VS Code for Linux mean that Microsoft
> now fully supports .Net on Linux too? This is a development I haven't really
> kept up with, not being a windows user.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/5eEbnwzbQvo/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Refactoring application to extract model, update and some actions

2017-02-06 Thread 'Rupert Smith' via Elm Discuss
On Saturday, February 4, 2017 at 11:29:44 PM UTC, Pierre-Henri Trivier 
wrote:
>
> To anyone reading, I might have solved it myself : 
> https://phtrivier.github.io/2017/02/05/elm-tail-end-part-5.html
>

What you are referring to as a callback is often called a 'tagger' in Elm. 
I don't think this is an official name for it, just something I have seen 
in a few code bases I have peeked into, and a convention I have also 
adopted. Its a function to 'tag' values as msgs.

I would avoid the term callback, as its just a function. In imperative or 
OO programming you might call something a callback as it is a more exotic 
concept there. In FP its just functions calling 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: Again: which editor do you like best for Elm?

2017-02-06 Thread 'Rupert Smith' via Elm Discuss
On Saturday, February 4, 2017 at 7:35:37 AM UTC, GordonBGood wrote:

> I'm using Visual Studio Code with the Elm plug-in.  Works pretty well. 
>

BTW, does the fact that Microsoft have VS Code for Linux mean that 
Microsoft now fully supports .Net on Linux too? This is a development I 
haven't really kept up with, not being a windows user.

-- 
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: 0.18 Chaining Http requests

2017-02-06 Thread Kingsley Hendrickse
Oh that's exactly what I needed to understand :) thanks

-- 
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: 0.18 Chaining Http requests

2017-02-06 Thread Dmitry Utkin
I guess what you need here is 
Task.andThen 
http://package.elm-lang.org/packages/elm-lang/core/latest/Task#andThen

See this snippet I've found on 
github 
https://github.com/fpapado/elm-flickr-gallery/blob/c040f61575f4f47ce216df1820b42d1751ccdb7a/src/Main.elm#L56

Hope it helps.

On Monday, February 6, 2017 at 10:46:08 AM UTC+2, Kingsley Hendrickse wrote:
>
> Thanks
>
> I don't quite understand how to chain using Task
>
> I want to first do getCurrentUser Http request and then do 
> notifyOnLocationChange a regular task - but I can't understand how Task 
> could do this.
> Even chaining 2 http requests I don't understand since in order to fire a 
> Task you have use Task.perform or Task.attempt giving them the Msg - this 
> doesn't seem doable with Task
>
> getCurrentUser : Cmd Msg
> getCurrentUser =
>   Http.toTask (Http.get "/currentUser" decodeLogin)
>   |> Task.attempt CurrentUserResponse
>
>
> notifyOnLocationChange: Cmd Msg
> notifyOnLocationChange location =
>   Task.perform OnLocationChange (succeed location)
>
>
> any help appreciated 
>
>
>
> On Sunday, 5 February 2017 20:34:56 UTC, John Kelly wrote:
>>
>> Take a look at toTask: 
>> http://package.elm-lang.org/packages/elm-lang/http/1.0.0/Http#toTask
>
>

-- 
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: Giving elm-vim some love

2017-02-06 Thread Noah Gordon
As an exclusive vim user, this is something I'm interested in. I have zero 
vimscript but I'm willing to learn and give it a stab.

On Monday, February 6, 2017 at 12:17:18 AM UTC-5, Max Goldstein wrote:
>
> I would love to see better vim support, but I don't have the vimscript 
> knowledge either to make it happen.
>

-- 
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: Elm Routing with Navigation in 0.18

2017-02-06 Thread Wouter In t Velt
Op zondag 5 februari 2017 20:51:03 UTC+1 schreef Kingsley Hendrickse:
>
> I'm struggling a bit to get what I want out of the Route and Navigation 
> libraries.
>

Some time ago, I wrote a couple of posts diving into Navigation and Routing 
in Elm:
https://medium.com/elm-shorts/choosing-the-right-elm-spa-architecture-d6e8275f6899?source=collection_home---5--1--
https://medium.com/elm-shorts/more-on-spa-navigation-in-elm-31a066c6b9ae?source=collection_home---5--3--

Hope this helps! 

-- 
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: 0.18 Chaining Http requests

2017-02-06 Thread Matthieu Pizenberg
Hi Kingsley,

Regarding point 2, the Http.send 
 
function enables you to create Cmd messages from http requests, and as you 
mentionned, Cmd.batch 
 
can group any Cmd messages together. Order of treatment of these commands 
however is not guaranted in my understanding.

Regarding point 1, if these are async (like http requests) my feelings are 
that you have no other choice than using the update function. This is 
because you need an effect manager for this. I guess you could also make 
your own effect manager but this seems to be something that is not 
encouraged in the community, and not documented.
If you go the task way, the key functions are:
toTask : Request a -> Task Error a
andThen : (a -> Task x b) -> Task x a -> Task x b
attempt : (Result x a -> msg) -> Task x a -> Cmd msg
So you can chain your tasks with andThen, and finally once the "big" 
chained task is complete, create a command message with attempt.

This said, if your purpose is dealing with navigation, don't hesitate to 
look at those two interesting articles from Wouter :
https://medium.com/elm-shorts/more-on-spa-navigation-in-elm-31a066c6b9ae#.fnu1ejfzk
https://medium.com/elm-shorts/choosing-the-right-elm-spa-architecture-d6e8275f6899#.qk45rxw8n

Happy coding,
Matthieu


On Sunday, February 5, 2017 at 8:51:03 PM UTC+1, Kingsley Hendrickse wrote:
>
> Hi, 
>
> I've just started learning Elm and am using version 0.18.
>
> I want to do 2 things:
>
> 1. Make an http get and use the result to make another get request
> 2. Make 3 http requests (I don't mind whether they happen concurrently or 
> one after the other)
>
> Anyway after googling I found that in the previous version of Elm the Http 
> operations were done using Tasks. So on Task there was an andThen which 
> could be used.
>
> But in 0.18 it seems the new way of doing things is with Http send - but I 
> don't see how I can chain Http requests using the new send mechanism. It 
> also seems that in the 0.17 version you could 
> process the result inline but in 0.18 you have to use the update 
> mechanism. But that would suggest I would need to do a single http request 
> using send and capture the result in the update and then fire off another 
> send from the update - and catch it's result in the update again. Is that 
> how I should chain http requests in 0.18? 
>
> I like how Cmd.batch can take a list of Cmd's to run - it would be nice if 
> there was an equivalent for doing Http requests.
>
> Any pointers would be appreciated
>
> --Kingsley
>

-- 
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: Elm Routing with Navigation in 0.18

2017-02-06 Thread Kingsley Hendrickse
Ah awesome thanks - that's very helpul

On Sunday, 5 February 2017 21:57:36 UTC, Keith Lazuka wrote:
>
> In terms of sending an HTTP request when navigating to the Login page, you 
> should be able to do that by returning an Http Cmd in your `update` 
> function.
>
> Elm's Navigation library provides a special `program` function which--in 
> addition to the standard init/update/view/subscription functions used by 
> Html.program--also  takes a function from `Navigation.Location` to a 
> message that your update function can understand. In the example program 
> included in the Navigation library, this function is called `UrlChange`.
>
> So in your `update` function, you probably already have a case that 
> listens for this `UrlChange` message, computes a "route" from the 
> `Location` attached to this message, and stores the new route in your 
> model. 
>
> update msg model =
>   case msg of
> UrlChange location ->
>   ( { model | route = routeFromLocation location }
>   , Cmd.none
>   )
>
>
> All you need to do is change this case so that in addition to returning 
> the updated model, it looks at the new route and returns a Cmd based on 
> whether the new route is Login or not. 
>
> e.g.
>
> update msg model =
>   case msg of
> UrlChange location ->
>let
>newRoute = 
> routeFromLocation location
>
>newCmd =
> case newRoute of
>   Just (Route.Login) ->
>   Http.get "/api/loginStuff" stuffDecoder 
>   |> Http.send GotStuff
>   
>   _ ->
>   Cmd.none
>in
>( { model | route = newRoute }
>, newCmd 
>)
>
>
> On Sunday, February 5, 2017 at 11:51:03 AM UTC-8, Kingsley Hendrickse 
> wrote:
>>
>> Hi, 
>>
>> I'm new to elm and am using version 0.18
>>
>> I'm struggling a bit to get what I want out of the Route and Navigation 
>> libraries.
>>
>> I have 2 features Login and Registration 
>>
>> In the Main.elm I use an update which delegates to either the Login or 
>> Registration features and then updates the main model after Login or 
>> Registration has done its thing.
>>
>> However I want to be able to detect when I'm going to show the Login view 
>> and before the view is rendered fire off an http request which will be used 
>> to populate the view. I can't see how to do this. It's easy to do as a 
>> result of something like a button click - because then the trigger point is 
>> the button click. But I want the trigger point to be during navigation so 
>> that the user can arrive on a page and that initial arrival on the page 
>> triggers the http requests that will be used in that view. 
>>
>> Also if anyone could point me in the direction of a good pattern for 
>> protecting routes that would be great - e.g. if a user is not logged in 
>> they should not be allowed to go to the welcome page and get redirected to 
>> login, and if logged in they should be redirected to welcome and not 
>> allowed on login or registration etc ...
>>
>> Any help appreciated
>>
>> Thanks
>>
>> --Kingsley
>>
>

-- 
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: 0.18 Chaining Http requests

2017-02-06 Thread Kingsley Hendrickse
Thanks

I don't quite understand how to chain using Task

I want to first do getCurrentUser Http request and then do 
notifyOnLocationChange a regular task - but I can't understand how Task 
could do this.
Even chaining 2 http requests I don't understand since in order to fire a 
Task you have use Task.perform or Task.attempt giving them the Msg - this 
doesn't seem doable with Task

getCurrentUser : Cmd Msg
getCurrentUser =
  Http.toTask (Http.get "/currentUser" decodeLogin)
  |> Task.attempt CurrentUserResponse


notifyOnLocationChange: Cmd Msg
notifyOnLocationChange location =
  Task.perform OnLocationChange (succeed location)


any help appreciated 



On Sunday, 5 February 2017 20:34:56 UTC, John Kelly wrote:
>
> Take a look at toTask: 
> http://package.elm-lang.org/packages/elm-lang/http/1.0.0/Http#toTask

-- 
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] elm-lang/http and evancz/elm-http

2017-02-06 Thread Gordon Klaus
Sure enough.  I'll close mine.

On Sun, Feb 5, 2017 at 9:45 PM, Nick H  wrote:

> Gordon, I think I beat you to it. https://github.com/evancz/elm-
> http/pull/54
>
> On Sat, Feb 4, 2017 at 2:59 AM, Gordon Klaus 
> wrote:
>
>> I also stumbled over the switch from evancz/elm-http to elm-lang/http.
>> So I created https://github.com/evancz/elm-http/pull/56.  I suggest you
>> do the same for other moved packages.
>>
>> A complementary enhancement would be to automatically display the
>> `elm-version` string on each package.elm-lang.org page.  Maybe even
>> showing it in bright red when it doesn't include the latest Elm version.
>> Thoughts?
>>
>>
>> On Tuesday, January 31, 2017 at 7:37:50 AM UTC+1, Andrew Radford wrote:
>>>
>>> This sort of thing happens a lot (that and re-naming like
>>> elm-linear-algebra to just linear-algebra). bit of a trap for new users.
>>> I wonder if there is a formal way to leave a trail to the superseding
>>> package. The old packages usually still get a lot of hits from Google and
>>> references from projects still using them.
>>>
>>>
>>> On Tuesday, 31 January 2017 04:17:18 UTC, Nick H wrote:

 They are the same library. elm-http was migrated from evancz/ to
 elm-lang/ when 0.18 was released, so only the latter will work. I guess the
 URL function was removed.



 On Mon, Jan 30, 2017 at 3:05 PM, Brian Marick 
 wrote:

> I’m confused by the relationship between these two libraries. They
> seem to overlap in functionality, but only the latter has `url` (
> http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#url)
> which seems pretty basic.
>
> Where’s the right place to find a URL-construction function?
>
> --
> 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...@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.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/nEsmgh4LD4A/unsubscribe.
> To unsubscribe from this group and all its topics, 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.