Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (55 sloc) 1.5 KB
module Bob exposing (bob)
import Html exposing (h1, div, text, input, button)
import Html.Events exposing (onInput, onClick)
import Regex
type Msg
= NewInput String
| Asked
type alias Model =
( String, String )
main : Program Never Model Msg
main =
Html.program
{ init = ( ( "", "" ), Cmd.none )
, view = view
, update = update
, subscriptions = (\x -> Sub.none)
}
view : Model -> Html.Html Msg
view ( pre, pending ) =
div []
[ div []
[ input [ onInput NewInput ] []
, button [ onClick Asked ] [ text "Say it to Bob!" ]
]
, text (hey pending)
]
update : Msg -> Model -> ( Model, Cmd Msg )
update msg ( pre, pending ) =
case msg of
NewInput str ->
( ( str, pending ), Cmd.none )
Asked ->
( ( pre, pre ), Cmd.none )
bob : String
bob =
"Hello, World!"
hey : String -> String
hey words =
case String.length (String.trim words) == 0 of
True ->
"Fine. Be that way!"
False ->
case
Regex.contains (Regex.regex "[A-z]+") words
&& String.toUpper words
== words
of
True ->
"Whoa, chill out!"
False ->
case String.endsWith "?" words of
True ->
"Sure."
False ->
"Whatever."
You can’t perform that action at this time.