<commit_before>module ColorPicker where

import Html exposing (text, div)
import Html.Attributes exposing (style)
import Html.Events exposing (..)

optionView address color =
  div
    [onClick address color]
    [text color]

answerView color =
  div
    [style
      [
        ("background-color", color),
        ("height", "100px"),
        ("width", "100px")]]
    []

view address options guess =
  let
    answer' = answerView options.answer
    option' = optionView address
    options' = div [] (List.map option' options.options)
    prompt = if guess == "" then "Pick a color!" else ""
    promptView = div [] [text prompt]
    rightOrWrong = if guess /= "" then
                     if guess == options.answer then "Right!" else "Wrong!"
                   else
                     ""
    rightOrWrongView = div [] [text rightOrWrong]
  in
    div
      []
      [
        answer',
        options',
        promptView,
        rightOrWrongView
      ]

type alias GameObject = {
  answer : String,
  options : List String
}

port options : Signal GameObject

guessInbox =
  Signal.mailbox ""

guess =
  guessInbox.signal

main =
  Signal.map2 (view guessInbox.address) options guess<commit_msg>guess now uses a Maybe<commit_after>module ColorPicker where

import Html exposing (text, div)
import Html.Attributes exposing (style)
import Html.Events exposing (..)
import Maybe exposing (Maybe(Just, Nothing))

optionView address color =
  div
    [onClick address (Just color)]
    [text color]

answerView color =
  div
    [style
      [
        ("background-color", color),
        ("height", "100px"),
        ("width", "100px")]]
    []

view address options guess =
  let
    answer' = answerView options.answer
    option' = optionView address
    options' = div [] (List.map option' options.options)
    hasGuess = case guess of
                 Just _ -> True
                 Nothing -> False
    guess' = Maybe.withDefault "" guess
    prompt = if hasGuess then "" else "Pick a color!"
    promptView = div [] [text prompt]
    rightOrWrong = if hasGuess then
                     if guess' == options.answer then "Right!" else "Wrong!"
                   else
                     ""
    rightOrWrongView = div [] [text rightOrWrong]
  in
    div
      []
      [
        answer',
        options',
        promptView,
        rightOrWrongView
      ]

type alias GameObject = {
  answer : String,
  options : List String
}

port options : Signal GameObject

guessInbox =
  Signal.mailbox Nothing

guess =
  guessInbox.signal

main =
  Signal.map2 (view guessInbox.address) options guess
{'fraction_non_alphanumeric': 0.09961685823754789, 'fraction_numerical': 0.0053639846743295016, 'mean_word_length': 2.223456790123457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3897432', 'n_tokens_mistral': 779, 'n_tokens_neox': 752, 'n_words': 233}