An alternate approach is just to use 'never' from 
elm-community/basics-extra directly for your '[WHAT HERE?]'. Although the 
error case actually comes first, so your example should be

Task.perform [WHAT HERE?] NewEntry Time.now

and my preferred answer would be (assuming 'import Basics.Extra exposing 
(never)')

Task.perform never NewEntry Time.now

It ends up being exactly the same thing under the hood - I just prefer this 
version because I find it very explicit, it's a little bit shorter, and 
most importantly it builds a nice solution out of little generic, modular 
pieces instead of using a more specialized function (if you can get used to 
how 'never' is used here, then you might be able to find uses for it 
elsewhere).

On Wednesday, 22 June 2016 21:53:20 UTC+10, Niklas Koponen wrote:
>
> Hi!
>
> I'm trying to get the current time in elm but I can't figure out how use 
> tasks. Now definition looks like this
>
> now : Task x Time
>
> The guide regarding tasks says:
>
> Second, notice that the error type is the type variable x. When we saw 
>> Http.getString it had a concrete error type Http.Error. The Time.now task 
>> is different in that it will not fail in a special way. You will always get 
>> the time back. This type variable x is basically saying “I am not going to 
>> force you to handle a particular type of errors” because it does not 
>> produce any.
>
>
> I have this message:
>
> NewEntry Time
>
> The problem is I don't know what to write for the error when I do 
> Task.perform
>
> Task.perform NewEntry [WHAT HERE?] Time.now
>
> -Niklas
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to