This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changePlayerName : PlayerModel -> String -> ScorekeeperModel -> ScorekeeperModel | |
changePlayerName playerToChange newName scorekeeperModel = | |
let | |
{ players } = | |
scorekeeperModel | |
in | |
{ scorekeeperModel | |
| players = | |
Exts.List.mergeBy | |
(.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CONTRACT | |
# SOURCE_SUBPRPOJECT_ROOT points to the "same" directory tree | |
# as TARGET_PROJECT_ROOT. We're extracting the directory tree | |
# at SOURCE_SUBPROJECT_ROOT into TARGET_PROJECT_ROOT. | |
# | |
# There must be a single, linear history in the SOURCE repository. | |
# Graft the current commit into the target | |
pushd "$SOURCE_SUBPROJECT_ROOT" | |
commit_comment="$(git log -1 --pretty=%B)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
playerDetailsViewModel : (PlayerId -> Int) -> PlayerModel -> PlayerDetailsViewModel | |
playerDetailsViewModel playerPointsScored playerModel = | |
PlayerDetailsViewModel | |
playerModel.id | |
playerModel.name | |
(playerPointsScored playerModel.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
divFor : (a -> List (Attribute msg)) -> (a -> List (Html msg)) -> a -> Html msg | |
divFor cssStylesFor bodyFor blob = | |
-- Given functions that generate attributes and HTML elements for a thing, | |
-- wrap it in a div. | |
div | |
(cssStylesFor blob) | |
(bodyFor blob) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This becomes the typical pop-up error message at the top of an HTML page | |
failureView : Result String Int -> List (Html Update) | |
failureView possibleNumericInput = | |
case possibleNumericInput of | |
Err message -> | |
[ text message ] | |
Ok _ -> | |
[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>JS Drum Kit</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// findPrice : String -> Option<Price> | |
// Option comes from Atlassian's fugue library https://docs.atlassian.com/fugue/4.3.0/fugue/apidocs/index.html | |
// I want the equivalent of | |
// case (maybePrice) { | |
// none => display.displayProductNotFoundMessage(barcode) | |
// some(price) => display.displayPrice(price) | |
// } | |
catalog.findPrice(barcode) | |
.<Runnable>fold( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ca.jbrains.pos; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.net.InetAddress; | |
import java.util.HashMap; | |
public class PointOfSaleTerminal { | |
public static void main(String[] args) throws IOException { | |
final InputStreamReader commandSource = new InputStreamReader(System.in); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new StreamTextCommands() | |
.streamCommandsFrom(new InputStreamReader(System.in)) | |
.map(String::trim) | |
.filter((command) -> !command.isEmpty()) | |
.map(commandText -> sellOneItemController.onBarcode(commandText)) | |
.map(CommandResponse::render) | |
.forEach(System.out::println); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public CommandResponse onBarcode(String barcode) { | |
Price price = catalog.findPrice(barcode); | |
return price == null | |
? new ProductNotFoundMessage(barcode) | |
: new ProductFoundMessage(price); | |
} |