This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Board.Internals

, (&>) , Mode , ModePacker , ModelToState , TaskModelToState , liftToAsync , AnswerValue , Answer , StateHandler , Msg

module Board.Internals exposing (..)

{-| 
@docs (=>)
    , (&>)
    , Mode
    , ModePacker
    , ModelToState
    , TaskModelToState
    , liftToAsync
    , AnswerValue
    , Answer
    , StateHandler
    , Msg
-}

import Board.Shared exposing (..)
import Task exposing (Task)


{-|
-}
(=>) : a -> b -> b
(=>) t1 t2 =
    t2


{-|
-}
(&>) : Task x a -> b -> Task x b
(&>) task v =
    Task.map (\_ -> v) task


{-|
-}
type Mode error value
    = Async (Task.Task error value)
    | Sync value


{-|
-}
type alias ModePacker answer value model error = 
    answer -> Mode error (Answer value model error)


{-|
-}
type alias ModelToState value model error =
    (model -> ( model, AnswerValue value model error ))


{-|
-}
type alias TaskModelToState value model error =
    Task error (model -> ( model, AnswerValue value model error ))


{-|
-}
liftToAsync : Mode error a -> Task.Task error a
liftToAsync value =
    case value of 
        Sync answer ->
            Task.succeed answer 
        
        Async task ->
            task


{-|
-}
type AnswerValue value model error
    = Redirect String
    | Reply (Response value)
    | Next (Request value)


{-|
-}
type Answer value model error
    = StateFull (StateHandler value model error) 
    | StateLess (AnswerValue value model error)


{-|
-}
type alias StateHandler value model error =
    (model -> (model, Mode error (Answer value model error)) )


{-|
-}
type Msg value model error
    = Input (Request value)
    | Output (Response value)
    | Error String
    | Model (StateHandler value model error) (Request value)
    | Test String