├── .watchmanconfig ├── .babelrc ├── elm-stuff ├── packages │ ├── elm-lang │ │ ├── html │ │ │ └── 2.0.0 │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── elm-package.json │ │ │ │ ├── properties-vs-attributes.md │ │ │ │ ├── src │ │ │ │ └── Html │ │ │ │ │ ├── Keyed.elm │ │ │ │ │ └── Lazy.elm │ │ │ │ └── LICENSE │ │ ├── http │ │ │ └── 1.0.0 │ │ │ │ ├── .gitignore │ │ │ │ ├── elm-package.json │ │ │ │ ├── src │ │ │ │ └── Http │ │ │ │ │ └── Internal.elm │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ └── rate-limit.md │ │ ├── core │ │ │ └── 5.1.1 │ │ │ │ ├── .gitignore │ │ │ │ ├── tests │ │ │ │ ├── run-tests.sh │ │ │ │ ├── elm-package.json │ │ │ │ ├── Main.elm │ │ │ │ └── Test │ │ │ │ │ ├── Set.elm │ │ │ │ │ ├── Equality.elm │ │ │ │ │ ├── Regex.elm │ │ │ │ │ ├── Result.elm │ │ │ │ │ ├── CodeGen.elm │ │ │ │ │ ├── Bitwise.elm │ │ │ │ │ ├── Json.elm │ │ │ │ │ ├── Char.elm │ │ │ │ │ └── String.elm │ │ │ │ ├── src │ │ │ │ ├── Native │ │ │ │ │ ├── Bitwise.js │ │ │ │ │ ├── Debug.js │ │ │ │ │ ├── Char.js │ │ │ │ │ ├── Time.js │ │ │ │ │ ├── Date.js │ │ │ │ │ ├── List.js │ │ │ │ │ ├── Basics.js │ │ │ │ │ └── Regex.js │ │ │ │ ├── Platform │ │ │ │ │ ├── Sub.elm │ │ │ │ │ └── Cmd.elm │ │ │ │ ├── Tuple.elm │ │ │ │ ├── Debug.elm │ │ │ │ ├── Json │ │ │ │ │ └── Encode.elm │ │ │ │ ├── Bitwise.elm │ │ │ │ ├── Char.elm │ │ │ │ ├── Date.elm │ │ │ │ ├── Process.elm │ │ │ │ ├── Platform.elm │ │ │ │ ├── Maybe.elm │ │ │ │ ├── Set.elm │ │ │ │ └── Regex.elm │ │ │ │ ├── elm-package.json │ │ │ │ ├── README.md │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ └── changelog.md │ │ └── virtual-dom │ │ │ └── 2.0.4 │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── README.md │ │ │ ├── tests │ │ │ ├── TestMain.elm │ │ │ ├── elm-package.json │ │ │ ├── run-tests.sh │ │ │ ├── TestHelpers.elm │ │ │ ├── Native │ │ │ │ └── TestHelpers.js │ │ │ └── TestCases │ │ │ │ └── Lazy.elm │ │ │ ├── elm-package.json │ │ │ ├── LICENSE │ │ │ └── src │ │ │ └── VirtualDom │ │ │ ├── Report.elm │ │ │ └── Helpers.elm │ └── NoRedInk │ │ └── elm-decode-pipeline │ │ └── 3.0.0 │ │ ├── tests │ │ ├── .gitignore │ │ ├── Main.elm │ │ ├── elm-package.json │ │ └── Tests.elm │ │ ├── .gitignore │ │ ├── elm-package.json │ │ ├── examples │ │ └── Example.elm │ │ ├── LICENSE │ │ └── README.md └── exact-dependencies.json ├── .elm-native-ui-version ├── android ├── settings.gradle ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── ask │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ └── AndroidManifest.xml │ │ └── release │ │ │ └── AndroidManifest.xml │ ├── BUCK │ └── proguard-rules.pro ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── keystores │ ├── debug.keystore.properties │ └── BUCK ├── build.gradle ├── gradle.properties └── gradlew.bat ├── bin ├── yarn.lock ├── setup └── sync-elm-native-ui ├── ios ├── Default-568h@2x.png ├── whendovescryriff.caf ├── FarmStatsTW │ ├── Images.xcassets │ │ ├── Contents.json │ │ ├── AppIcon.debug.appiconset │ │ │ ├── Icon.png │ │ │ ├── Icon-60.png │ │ │ ├── Icon-72.png │ │ │ ├── Icon-76.png │ │ │ ├── Icon@2x.png │ │ │ ├── Icon-60@2x.png │ │ │ ├── Icon-60@3x.png │ │ │ ├── Icon-72@2x.png │ │ │ ├── Icon-76@2x.png │ │ │ ├── Icon-Small.png │ │ │ ├── Icon-hdpi.png │ │ │ ├── Icon-ldpi.png │ │ │ ├── Icon-mdpi.png │ │ │ ├── Icon-xhdpi.png │ │ │ ├── Icon-xxhdpi.png │ │ │ ├── Icon-Small-40.png │ │ │ ├── Icon-Small-50.png │ │ │ ├── Icon-Small@2x.png │ │ │ ├── Icon-xxxhdpi.png │ │ │ ├── Icon-Small-40@2x.png │ │ │ ├── Icon-Small-50@2x.png │ │ │ └── Contents.json │ │ └── AppIcon.release.appiconset │ │ │ ├── purple-train-29x29.png │ │ │ ├── purple-train-40x40.png │ │ │ ├── purple-train-48x48.png │ │ │ ├── purple-train-72x72.png │ │ │ ├── purple-train-76x76.png │ │ │ ├── purple-train-144x144.png │ │ │ ├── purple-train-29x29@2x.png │ │ │ ├── purple-train-29x29@3x.png │ │ │ ├── purple-train-40x40@2x.png │ │ │ ├── purple-train-40x40@3x.png │ │ │ ├── purple-train-512x512.png │ │ │ ├── purple-train-60x60@2x.png │ │ │ ├── purple-train-60x60@3x.png │ │ │ ├── purple-train-76x76@2x.png │ │ │ ├── purple-train-29x29@2x-1.png │ │ │ ├── purple-train-29x29@3x-1.png │ │ │ ├── purple-train-40x40@2x-1.png │ │ │ ├── purple-train-40x40@3x-1.png │ │ │ ├── purple-train-512x512@2x.png │ │ │ ├── purple-train-60x60@2x-1.png │ │ │ ├── purple-train-60x60@3x-1.png │ │ │ └── purple-train-83.5x83.5@2x.png │ ├── FarmStatsTW.entitlements │ ├── AppDelegate.h │ ├── main.m │ ├── Info.plist │ ├── Base.lproj │ │ └── LaunchScreen.xib │ └── AppDelegate.m ├── purple-train-512x512@2x.png ├── FarmStatsTWTests │ ├── Info.plist │ └── FarmStatsTWTests.m └── FarmStatsTW.xcodeproj │ └── xcshareddata │ └── xcschemes │ └── Release.xcscheme ├── src ├── Api.elm ├── Subscription.elm ├── Message.elm ├── Model.elm ├── Types.elm ├── Web.elm ├── Update.elm └── Mobile.elm ├── app └── assets │ └── fonts │ ├── HK Compakt.otf │ ├── HK Compakt_bold.otf │ └── Roboto Condensed.ttf ├── .buckconfig ├── index.android.js ├── index.ios.js ├── __tests__ ├── index.ios.js └── index.android.js ├── .gitignore ├── elm-package.json ├── package.json ├── LICENSE ├── README.md ├── init-push-notifications.ios.js └── .flowconfig /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff -------------------------------------------------------------------------------- /.elm-native-ui-version: -------------------------------------------------------------------------------- 1 | 35d74990bb460396f446d6c24759c0051dfeb240 2 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FarmStatsTW' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /elm-stuff/ 2 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff 2 | tests/test.js 3 | node_modules/ -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | elm-stuff 3 | tests/build 4 | -------------------------------------------------------------------------------- /bin/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | -------------------------------------------------------------------------------- /ios/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/Default-568h@2x.png -------------------------------------------------------------------------------- /ios/whendovescryriff.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/whendovescryriff.caf -------------------------------------------------------------------------------- /src/Api.elm: -------------------------------------------------------------------------------- 1 | module Api exposing (..) 2 | 3 | baseUrl : String 4 | baseUrl = "http://13.115.226.214:9999/api/trades?" -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FarmStatsTW 3 | 4 | -------------------------------------------------------------------------------- /app/assets/fonts/HK Compakt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/app/assets/fonts/HK Compakt.otf -------------------------------------------------------------------------------- /ios/purple-train-512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/purple-train-512x512@2x.png -------------------------------------------------------------------------------- /app/assets/fonts/HK Compakt_bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/app/assets/fonts/HK Compakt_bold.otf -------------------------------------------------------------------------------- /app/assets/fonts/Roboto Condensed.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/app/assets/fonts/Roboto Condensed.ttf -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/.gitignore: -------------------------------------------------------------------------------- 1 | # elm-package generated files 2 | elm-stuff/ 3 | # elm-repl generated files 4 | repl-temp-* 5 | -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if ! command -v yarn >/dev/null; then 6 | npm install -g yarn 7 | fi 8 | 9 | yarn install 10 | 11 | ./bin/sync-elm-native-ui 12 | -------------------------------------------------------------------------------- /src/Subscription.elm: -------------------------------------------------------------------------------- 1 | module Subscription exposing (..) 2 | import Model exposing (..) 3 | import Message exposing (..) 4 | 5 | subscriptions : Model -> Sub Msg 6 | subscriptions model = Sub.none -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon.png -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: none 3 | install: 4 | - npm install --global elm@0.16.0 5 | - npm install 6 | 7 | script: 8 | - ./tests/run-tests.sh -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-72.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-76.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon@2x.png -------------------------------------------------------------------------------- /index.android.js: -------------------------------------------------------------------------------- 1 | const { AppRegistry } = require('react-native') 2 | const Elm = require('./elm') 3 | const component = Elm.Main.start() 4 | 5 | AppRegistry.registerComponent('FarmStatsTW', () => component) 6 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-72@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-hdpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-ldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-ldpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-mdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-mdpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xhdpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xxhdpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-40.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-50.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-xxxhdpi.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Icon-Small-50@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-48x48.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-72x72.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-76x76.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-144x144.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@3x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@3x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-512x512.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@3x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-76x76@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@2x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@3x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-29x29@3x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@2x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@3x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-40x40@3x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-512x512@2x.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@2x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@3x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-60x60@3x-1.png -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sovmedcare/hackthon-farm-stats-tw/HEAD/ios/FarmStatsTW/Images.xcassets/AppIcon.release.appiconset/purple-train-83.5x83.5@2x.png -------------------------------------------------------------------------------- /src/Message.elm: -------------------------------------------------------------------------------- 1 | module Message exposing (..) 2 | 3 | import Types exposing (..) 4 | import Http 5 | 6 | type Msg 7 | = NoOp 8 | | ChangeSearchInput String 9 | | ClickSearch 10 | | NewPriceData (Result Http.Error Response) 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/FarmStatsTW.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /elm-stuff/exact-dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "elm-lang/virtual-dom": "2.0.4", 3 | "elm-lang/http": "1.0.0", 4 | "mgold/elm-date-format": "1.4.1", 5 | "elm-lang/html": "2.0.0", 6 | "elm-lang/core": "5.1.1", 7 | "NoRedInk/elm-decode-pipeline": "3.0.0", 8 | "ohanhi/elm-native-ui": "2.0.0" 9 | } -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | const { AppRegistry } = require('react-native') 2 | const Elm = require('./elm') 3 | 4 | import initPushNotifications from './init-push-notifications' 5 | 6 | const component = Elm.Main.start(app => { 7 | initPushNotifications(app) 8 | }) 9 | 10 | AppRegistry.registerComponent('FarmStatsTW', () => component) 11 | -------------------------------------------------------------------------------- /__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /src/Model.elm: -------------------------------------------------------------------------------- 1 | module Model exposing (Model, init) 2 | import Message exposing (Msg) 3 | import Types exposing (..) 4 | 5 | type alias Model = 6 | { searchInput : String 7 | , searched: Bool 8 | , data : PriceData 9 | } 10 | 11 | init : ( Model, Cmd Msg ) 12 | init = 13 | ( { searchInput = "香蕉", searched = False, data = []} 14 | , Cmd.none 15 | ) -------------------------------------------------------------------------------- /android/app/src/release/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/tests/Main.elm: -------------------------------------------------------------------------------- 1 | port module Main exposing (..) 2 | 3 | {-| 4 | Run the tests with node-test-runner: 5 | 6 | https://github.com/rtfeldman/node-test-runner 7 | -} 8 | 9 | import Tests 10 | import Test.Runner.Node exposing (run) 11 | import Json.Encode exposing (Value) 12 | 13 | 14 | main : Program Never 15 | main = 16 | run emit Tests.all 17 | 18 | 19 | port emit : ( String, Value ) -> Cmd msg 20 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/README.md: -------------------------------------------------------------------------------- 1 | # Virtual DOM for Elm 2 | 3 | A virtual DOM implementation that backs Elm's core libraries for [HTML](http://package.elm-lang.org/packages/elm-lang/html/latest/) and [SVG](http://package.elm-lang.org/packages/elm-lang/svg/latest/). You should almost certainly use those higher-level libraries directly. 4 | 5 | It is pretty fast! You can read about that [here](http://elm-lang.org/blog/blazing-fast-html-round-two). 6 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/README.md: -------------------------------------------------------------------------------- 1 | # HTML for Elm 2 | 3 | The core HTML library for Elm. It is backed by [elm-lang/virtual-dom](http://package.elm-lang.org/packages/elm-lang/virtual-dom/latest/) which handles the dirty details of rendering things quickly. 4 | 5 | The best way to learn how to use this library is to read [guide.elm-lang.org](http://guide.elm-lang.org/), particularly the section on [The Elm Architecture](http://guide.elm-lang.org/architecture/index.html). 6 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/ask/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sovmedcare.farm_stats_tw; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "FarmStatsTW"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/TestMain.elm: -------------------------------------------------------------------------------- 1 | 2 | import ElmTest.Runner.Console exposing (runDisplay) 3 | import ElmTest.Test exposing (Test, suite) 4 | import Console exposing (IO) 5 | import Task exposing (Task) 6 | 7 | import TestCases.Lazy 8 | 9 | tests : Test 10 | tests = 11 | suite 12 | "VirtualDom Library Tests" 13 | [ 14 | TestCases.Lazy.tests 15 | ] 16 | 17 | port runner : Signal (Task x ()) 18 | port runner = Console.run (runDisplay tests) 19 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "$(dirname "$0")" 4 | set -e 5 | 6 | 7 | elm-package install -y 8 | 9 | VERSION_DIR="$(ls elm-stuff/packages/elm-lang/core/)" 10 | CORE_PACKAGE_DIR="elm-stuff/packages/elm-lang/core/$VERSION_DIR" 11 | CORE_GIT_DIR="$(dirname $PWD)" 12 | 13 | echo "Linking $CORE_PACKAGE_DIR to $CORE_GIT_DIR" 14 | rm -rf $CORE_PACKAGE_DIR 15 | ln -s $CORE_GIT_DIR $CORE_PACKAGE_DIR 16 | 17 | elm-make --yes --output test.js Main.elm 18 | 19 | elm-test Main.elm 20 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Bitwise.js: -------------------------------------------------------------------------------- 1 | var _elm_lang$core$Native_Bitwise = function() { 2 | 3 | return { 4 | and: F2(function and(a, b) { return a & b; }), 5 | or: F2(function or(a, b) { return a | b; }), 6 | xor: F2(function xor(a, b) { return a ^ b; }), 7 | complement: function complement(a) { return ~a; }, 8 | shiftLeftBy: F2(function(offset, a) { return a << offset; }), 9 | shiftRightBy: F2(function(offset, a) { return a >> offset; }), 10 | shiftRightZfBy: F2(function(offset, a) { return a >>> offset; }) 11 | }; 12 | 13 | }(); 14 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.0.0", 3 | "summary": "A pipeline-friendly library for building JSON decoders.", 4 | "repository": "https://github.com/NoRedInk/elm-decode-pipeline.git", 5 | "license": "BSD-3-Clause", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [ 10 | "Json.Decode.Pipeline" 11 | ], 12 | "dependencies": { 13 | "elm-lang/core": "5.0.0 <= v < 6.0.0" 14 | }, 15 | "elm-version": "0.18.0 <= v < 0.19.0" 16 | } 17 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.4", 3 | "summary": "Core virtual DOM implementation, basis for HTML and SVG libraries", 4 | "repository": "https://github.com/elm-lang/virtual-dom.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [ 10 | "VirtualDom" 11 | ], 12 | "native-modules": true, 13 | "dependencies": { 14 | "elm-lang/core": "5.0.0 <= v < 6.0.0" 15 | }, 16 | "elm-version": "0.18.0 <= v < 0.19.0" 17 | } 18 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/examples/Example.elm: -------------------------------------------------------------------------------- 1 | module Example exposing (..) 2 | 3 | import Json.Decode exposing (int, string, float, Decoder) 4 | import Json.Decode.Pipeline exposing (decode, required, optional, hardcoded) 5 | 6 | 7 | type alias User = 8 | { id : Int 9 | , name : String 10 | , percentExcited : Float 11 | } 12 | 13 | 14 | userDecoder : Decoder User 15 | userDecoder = 16 | decode User 17 | |> required "id" int 18 | |> optional "name" string "(fallback if name not present)" 19 | |> hardcoded 1.0 20 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Debug.js: -------------------------------------------------------------------------------- 1 | //import Native.Utils // 2 | 3 | var _elm_lang$core$Native_Debug = function() { 4 | 5 | function log(tag, value) 6 | { 7 | var msg = tag + ': ' + _elm_lang$core$Native_Utils.toString(value); 8 | var process = process || {}; 9 | if (process.stdout) 10 | { 11 | process.stdout.write(msg); 12 | } 13 | else 14 | { 15 | console.log(msg); 16 | } 17 | return value; 18 | } 19 | 20 | function crash(message) 21 | { 22 | throw new Error(message); 23 | } 24 | 25 | return { 26 | crash: crash, 27 | log: F2(log) 28 | }; 29 | 30 | }(); -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "Make HTTP requests (download progress, rate-limit, debounce, throttle)", 4 | "repository": "https://github.com/elm-lang/http.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [ 10 | "Http", 11 | "Http.Progress" 12 | ], 13 | "native-modules": true, 14 | "dependencies": { 15 | "elm-lang/core": "5.0.0 <= v < 6.0.0" 16 | }, 17 | "elm-version": "0.18.0 <= v < 0.19.0" 18 | } 19 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.1.1", 3 | "summary": "Tests for Elm's standard libraries", 4 | "repository": "http://github.com/elm-lang/core.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | ".", 8 | "../src" 9 | ], 10 | "exposed-modules": [ ], 11 | "native-modules": true, 12 | "dependencies": { 13 | "elm-community/elm-test": "3.1.0 <= v < 4.0.0", 14 | "rtfeldman/node-test-runner": "3.0.0 <= v < 4.0.0" 15 | }, 16 | "elm-version": "0.18.0 <= v < 0.19.0" 17 | } 18 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/tests/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "Sample Elm Test", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD-3-Clause", 6 | "source-directories": [ 7 | ".", 8 | "../src" 9 | ], 10 | "exposed-modules": [], 11 | "dependencies": { 12 | "elm-lang/core": "5.0.0 <= v < 6.0.0", 13 | "elm-community/elm-test": "2.0.0 <= v < 3.0.0", 14 | "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" 15 | }, 16 | "elm-version": "0.18.0 <= v < 0.19.0" 17 | } 18 | -------------------------------------------------------------------------------- /src/Types.elm: -------------------------------------------------------------------------------- 1 | module Types exposing (..) 2 | 3 | type alias Response = 4 | { docs : PriceData 5 | , total : Int 6 | , limit : Int 7 | , page : Int 8 | , pages : Int 9 | } 10 | 11 | type alias Info = 12 | { tradeDate : String 13 | , cropCode : String 14 | , cropName : String 15 | , marketCode : String 16 | , marketName : String 17 | , highPrice : Float 18 | , middlePrice : Float 19 | , lowPrice : Float 20 | , avgPrice : Float 21 | , tradeCount : Float 22 | , updated : String 23 | , created : String 24 | } 25 | 26 | type alias PriceData = List Info -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "Test for VirtualDom", 4 | "license": "BSD3", 5 | "repository": "https://github.com/evancz/virtual-dom.git", 6 | "exposed-modules": [], 7 | "source-directories": [ 8 | ".", 9 | "build/virtual-dom/" 10 | ], 11 | "native-modules": true, 12 | "dependencies": { 13 | "elm-lang/core": "2.0.0 <= v < 4.0.0", 14 | "laszlopandy/elm-console": "1.0.0 <= v < 2.0.0", 15 | "deadfoxygrandpa/elm-test": "1.0.3 <= v < 2.0.0" 16 | }, 17 | "elm-version": "0.16.0 <= v < 0.17.0" 18 | } -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "summary": "Fast HTML, rendered with virtual DOM diffing", 4 | "repository": "https://github.com/elm-lang/html.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [ 10 | "Html", 11 | "Html.Attributes", 12 | "Html.Events", 13 | "Html.Keyed", 14 | "Html.Lazy" 15 | ], 16 | "dependencies": { 17 | "elm-lang/core": "5.0.0 <= v < 6.0.0", 18 | "elm-lang/virtual-dom": "2.0.0 <= v < 3.0.0" 19 | }, 20 | "elm-version": "0.18.0 <= v < 0.19.0" 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | *.iml 28 | .idea 29 | .gradle 30 | local.properties 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | 37 | # BUCK 38 | buck-out/ 39 | \.buckd/ 40 | android/app/libs 41 | android/keystores/debug.keystore 42 | android/app/*.keystore 43 | 44 | elm.js 45 | elm-stuff/* 46 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Char.js: -------------------------------------------------------------------------------- 1 | //import Native.Utils // 2 | 3 | var _elm_lang$core$Native_Char = function() { 4 | 5 | return { 6 | fromCode: function(c) { return _elm_lang$core$Native_Utils.chr(String.fromCharCode(c)); }, 7 | toCode: function(c) { return c.charCodeAt(0); }, 8 | toUpper: function(c) { return _elm_lang$core$Native_Utils.chr(c.toUpperCase()); }, 9 | toLower: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLowerCase()); }, 10 | toLocaleUpper: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLocaleUpperCase()); }, 11 | toLocaleLower: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLocaleLowerCase()); } 12 | }; 13 | 14 | }(); -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Time.js: -------------------------------------------------------------------------------- 1 | //import Native.Scheduler // 2 | 3 | var _elm_lang$core$Native_Time = function() { 4 | 5 | var now = _elm_lang$core$Native_Scheduler.nativeBinding(function(callback) 6 | { 7 | callback(_elm_lang$core$Native_Scheduler.succeed(Date.now())); 8 | }); 9 | 10 | function setInterval_(interval, task) 11 | { 12 | return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback) 13 | { 14 | var id = setInterval(function() { 15 | _elm_lang$core$Native_Scheduler.rawSpawn(task); 16 | }, interval); 17 | 18 | return function() { clearInterval(id); }; 19 | }); 20 | } 21 | 22 | return { 23 | now: now, 24 | setInterval_: F2(setInterval_) 25 | }; 26 | 27 | }(); -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "GPL-3.0", 6 | "source-directories": [ 7 | "./src" 8 | ], 9 | "exposed-modules": [], 10 | "native-modules": true, 11 | "dependencies": { 12 | "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0", 13 | "elm-lang/core": "5.0.0 <= v < 6.0.0", 14 | "elm-lang/html": "2.0.0 <= v < 3.0.0", 15 | "elm-lang/http": "1.0.0 <= v <= 1.0.0", 16 | "mgold/elm-date-format": "1.4.1 <= v < 2.0.0", 17 | "ohanhi/elm-native-ui": "2.0.0 <= v <= 2.0.0" 18 | }, 19 | "elm-version": "0.18.0 <= v < 0.19.0" 20 | } -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")" 6 | 7 | mkdir -p build/virtual-dom/Native 8 | cp ../src/VirtualDom.elm build/virtual-dom/ 9 | $(npm bin)/browserify ../src/wrapper.js -o build/VirtualDom.browser.js 10 | 11 | set +e 12 | diff -u ../src/Native/VirtualDom.js build/VirtualDom.browser.js 13 | if [ $? != 0 ]; then 14 | echo "ERROR:" 15 | echo "src/Native/VirtualDom.js has local modifications or is out of date. Please run rebuild.sh" 16 | exit 1 17 | fi 18 | set -e 19 | 20 | $(npm bin)/browserify --no-browser-field ../src/wrapper.js -o build/virtual-dom/Native/VirtualDom.js 21 | 22 | elm-make --yes --output build/test.js TestMain.elm 23 | echo "Elm.worker(Elm.Main);" >> build/test.js 24 | node build/test.js -------------------------------------------------------------------------------- /bin/sync-elm-native-ui: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echoerr() { 6 | echo "$@" 1>&2; 7 | } 8 | 9 | get_elm_native_version() { 10 | cut -d' ' -f1 .elm-native-ui-version 11 | } 12 | 13 | commit=$(get_elm_native_version) 14 | parent_dir="elm-stuff/packages/ohanhi/elm-native-ui" 15 | clone_path="$parent_dir/2.0.0/" 16 | repo="https://github.com/sovmedcare/elm-native-ui" 17 | 18 | mkdir -p $parent_dir 19 | 20 | if [[ -h "$clone_path" ]]; then 21 | echoerr "Ignoring symlinked directory" 22 | elif [[ -d "$clone_path" ]]; then 23 | echoerr "Updating Elm Native UI" 24 | git -C "$clone_path" fetch 25 | git -C "$clone_path" checkout "$commit" 26 | else 27 | echoerr "Cloning Elm Native UI" 28 | git clone "$repo" "$clone_path" 29 | git -C "$clone_path" checkout "$commit" 30 | fi 31 | -------------------------------------------------------------------------------- /ios/FarmStatsTWTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/src/Http/Internal.elm: -------------------------------------------------------------------------------- 1 | module Http.Internal exposing 2 | ( Request(..) 3 | , RawRequest 4 | , Expect 5 | , Body(..) 6 | , Header(..) 7 | , map 8 | ) 9 | 10 | 11 | import Native.Http 12 | import Time exposing (Time) 13 | 14 | 15 | 16 | type Request a = Request (RawRequest a) 17 | 18 | 19 | type alias RawRequest a = 20 | { method : String 21 | , headers : List Header 22 | , url : String 23 | , body : Body 24 | , expect : Expect a 25 | , timeout : Maybe Time 26 | , withCredentials : Bool 27 | } 28 | 29 | 30 | type Expect a = Expect 31 | 32 | 33 | type Body 34 | = EmptyBody 35 | | StringBody String String 36 | | FormDataBody 37 | 38 | 39 | 40 | type Header = Header String String 41 | 42 | 43 | map : (a -> b) -> RawRequest a -> RawRequest b 44 | map func request = 45 | { request | expect = Native.Http.mapExpect func request.expect } 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hackthon-farm-stats-tw", 3 | "version": "1.0.0", 4 | "private": false, 5 | "license": "MIT", 6 | "scripts": { 7 | "watch": "chokidar '**/*.elm' 'app/**/*.js' -c 'elm make src/Mobile.elm --output elm.js' --initial", 8 | "start": "node node_modules/react-native/local-cli/cli.js start", 9 | "test": "jest" 10 | }, 11 | "dependencies": { 12 | "react": "16.0.0-alpha.6", 13 | "react-native": "0.43.4", 14 | "react-native-scrollable-tab-view": "https://github.com/iancanderson/react-native-scrollable-tab-view.git#ia-tabbar-style-prop" 15 | }, 16 | "jest": { 17 | "preset": "jest-react-native" 18 | }, 19 | "devDependencies": { 20 | "babel-jest": "18.0.0", 21 | "babel-preset-react-native": "1.9.0", 22 | "chokidar-cli": "^1.2.0", 23 | "jest": "19.0.2", 24 | "jest-react-native": "18.0.0", 25 | "react-test-renderer": "16.0.0-alpha.6" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5.1.1", 3 | "summary": "Elm's standard libraries", 4 | "repository": "http://github.com/elm-lang/core.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [ 10 | "Array", 11 | "Basics", 12 | "Bitwise", 13 | "Char", 14 | "Color", 15 | "Date", 16 | "Debug", 17 | "Dict", 18 | "Json.Decode", 19 | "Json.Encode", 20 | "List", 21 | "Maybe", 22 | "Platform", 23 | "Platform.Cmd", 24 | "Platform.Sub", 25 | "Process", 26 | "Random", 27 | "Regex", 28 | "Result", 29 | "Set", 30 | "String", 31 | "Task", 32 | "Time", 33 | "Tuple" 34 | ], 35 | "native-modules": true, 36 | "dependencies": {}, 37 | "elm-version": "0.18.0 <= v < 0.19.0" 38 | } 39 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/TestHelpers.elm: -------------------------------------------------------------------------------- 1 | module TestHelpers where 2 | 3 | import VirtualDom exposing (Node) 4 | 5 | import Native.TestHelpers 6 | import Native.VirtualDom 7 | 8 | unsafeRecordCallCount : (a -> b) -> (a -> b) 9 | unsafeRecordCallCount = 10 | Native.TestHelpers.unsafeRecordCallCount 11 | 12 | unsafeQueryCallCount : (a -> b) -> Int 13 | unsafeQueryCallCount = 14 | Native.TestHelpers.unsafeQueryCallCount 15 | 16 | type OpaqueDom = OpaqueDom 17 | 18 | render : Node -> OpaqueDom 19 | render = 20 | Native.VirtualDom.render 21 | 22 | updateAndReplace : OpaqueDom -> Node -> Node -> OpaqueDom 23 | updateAndReplace = 24 | Native.TestHelpers.updateAndReplace 25 | 26 | 27 | renderDom : Node -> (OpaqueDom, Node) 28 | renderDom vdom = 29 | (render vdom, vdom) 30 | 31 | 32 | updateDom : (OpaqueDom, Node) -> Node -> (OpaqueDom, Node) 33 | updateDom (oldDom, oldVDom) newVDom = 34 | (updateAndReplace oldDom oldVDom newVDom, newVDom) 35 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/ask/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.sovmedcare.farm_stats_tw; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 18 | @Override 19 | protected boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | return Arrays.asList( 26 | new MainReactPackage() 27 | ); 28 | } 29 | }; 30 | 31 | @Override 32 | public ReactNativeHost getReactNativeHost() { 33 | return mReactNativeHost; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Guan Yu Pan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/Native/TestHelpers.js: -------------------------------------------------------------------------------- 1 | Elm.Native.TestHelpers = {}; 2 | Elm.Native.TestHelpers.make = function(localRuntime) 3 | { 4 | localRuntime.Native = localRuntime.Native || {}; 5 | localRuntime.Native.TestHelpers = localRuntime.Native.TestHelpers || {}; 6 | if (localRuntime.Native.TestHelpers.values) 7 | { 8 | return localRuntime.Native.TestHelpers.values; 9 | } 10 | 11 | var VirtualDom = Elm.Native.VirtualDom.make(localRuntime); 12 | 13 | function unsafeRecordCallCount(f) { 14 | function wrapper(a) { 15 | wrapper.__elm_test_call_count += 1; 16 | return f(a); 17 | } 18 | wrapper.__elm_test_call_count = 0; 19 | return wrapper; 20 | } 21 | 22 | function unsafeQueryCallCount(f) { 23 | if (f.__elm_test_call_count === undefined) { 24 | return -1; 25 | } 26 | return f.__elm_test_call_count; 27 | } 28 | 29 | Elm.Native.TestHelpers.values = { 30 | unsafeRecordCallCount: unsafeRecordCallCount, 31 | unsafeQueryCallCount: unsafeQueryCallCount, 32 | updateAndReplace: F3(VirtualDom.updateAndReplace) 33 | }; 34 | return localRuntime.Native.TestHelpers.values = Elm.Native.TestHelpers.values; 35 | }; -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Date.js: -------------------------------------------------------------------------------- 1 | //import Result // 2 | 3 | var _elm_lang$core$Native_Date = function() { 4 | 5 | function fromString(str) 6 | { 7 | var date = new Date(str); 8 | return isNaN(date.getTime()) 9 | ? _elm_lang$core$Result$Err('Unable to parse \'' + str + '\' as a date. Dates must be in the ISO 8601 format.') 10 | : _elm_lang$core$Result$Ok(date); 11 | } 12 | 13 | var dayTable = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; 14 | var monthTable = 15 | ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 16 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 17 | 18 | 19 | return { 20 | fromString: fromString, 21 | year: function(d) { return d.getFullYear(); }, 22 | month: function(d) { return { ctor: monthTable[d.getMonth()] }; }, 23 | day: function(d) { return d.getDate(); }, 24 | hour: function(d) { return d.getHours(); }, 25 | minute: function(d) { return d.getMinutes(); }, 26 | second: function(d) { return d.getSeconds(); }, 27 | millisecond: function(d) { return d.getMilliseconds(); }, 28 | toTime: function(d) { return d.getTime(); }, 29 | fromTime: function(t) { return new Date(t); }, 30 | dayOfWeek: function(d) { return { ctor: dayTable[d.getDay()] }; } 31 | }; 32 | 33 | }(); -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/README.md: -------------------------------------------------------------------------------- 1 | # Elm Core Libraries 2 | 3 | [![Build Status](https://travis-ci.org/elm-lang/core.svg?branch=master)](https://travis-ci.org/elm-lang/core) 4 | 5 | Every Elm project needs the core libraries. They provide basic functionality including: 6 | 7 | * The Basics — addition, subtraction, etc. 8 | * Data Structures — lists, dictionaries, sets, etc. 9 | 10 | 11 | ## Default Imports 12 | 13 | All Elm files have some default imports: 14 | 15 | ```elm 16 | import Basics exposing (..) 17 | import List exposing ( List, (::) ) 18 | import Maybe exposing ( Maybe( Just, Nothing ) ) 19 | import Result exposing ( Result( Ok, Err ) ) 20 | import String 21 | import Tuple 22 | 23 | import Debug 24 | 25 | import Platform exposing ( Program ) 26 | import Platform.Cmd exposing ( Cmd, (!) ) 27 | import Platform.Sub exposing ( Sub ) 28 | ``` 29 | 30 | The intention is to include things that are both extremely useful and very 31 | unlikely to overlap with anything that anyone will ever write in a library. 32 | By keeping the set of default imports small, it also becomes easier to use 33 | whatever version of `map` suits your fancy. Finally, it makes it easier to 34 | figure out where the heck a function is coming from. 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SOV黑客松 #1 : Farm Stats TW (台灣果菜市場價格查詢) 2 | 3 | 利用 elm, elm-native-ui (react-native) 製作台灣果菜市場價格查詢 4 | 5 | ### iOS preview 6 | ![](https://i.imgur.com/E2SdXxS.png) 7 | 8 | ### web preview 9 | ![](https://i.imgur.com/gHprryW.png) 10 | 11 | ## Setup 12 | 13 | ```js 14 | git clone https://github.com/sovmedcare/hackthon-farm-stats-tw 15 | yarn install 16 | ``` 17 | 18 | ## Development 19 | 20 | ```js 21 | // for dev (recompile elm) 22 | yarn watch 23 | // for running bundle on mobile simulator 24 | yarn start 25 | // for running web 26 | elm-reactor 27 | ``` 28 | 29 | ## 過程中可能會發生的問題 30 | 31 | Q: 重新 elm-package install 發生錯誤? 32 | A: 因為 elm-native-ui 不在 elm index 中, 所以必須另外安裝 33 | 34 | at current DIR 35 | 1. remove elm-staff 36 | 1. remove line of elm-native-ui in ```elm-package.json``` 37 | 1. elm-package install 38 | 39 | at parent DIR 40 | 1. git clone https://github.com/ohanhi/elm-native-ui 41 | 1. git clone https://github.com/NoRedInk/elm-ops-tooling 42 | 1. ```python elm-ops-tooling/elm_self_publish.py ./elm-native-ui ./hackthon-farm-stats-tw``` 43 | 44 | Q: Xcode 出現 compile error (React/RCTBridge.h) 45 | A: Product -> Scheme -> Manage Scheme -> Debug -> Build 46 | 47 | 1. uncheck Parallelize Build 48 | 1. click "+" -> Add React 49 | 1. move React to the top order 50 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | cache: 4 | directories: 5 | - test/elm-stuff/build-artifacts 6 | - sysconfcpus 7 | 8 | language: node_js 9 | 10 | node_js: 11 | - "4.3" 12 | 13 | before_install: 14 | - if [ ${TRAVIS_OS_NAME} == "osx" ]; 15 | then brew update; brew install nvm; mkdir ~/.nvm; export NVM_DIR=~/.nvm; source $(brew --prefix nvm)/nvm.sh; 16 | fi 17 | - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 18 | - | # epic build time improvement - see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142 19 | if [ ! -d sysconfcpus/bin ]; 20 | then 21 | git clone https://github.com/obmarg/libsysconfcpus.git; 22 | cd libsysconfcpus; 23 | ./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus; 24 | make && make install; 25 | cd ..; 26 | fi 27 | 28 | install: 29 | - npm install -g elm@0.18 elm-test 30 | - mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old 31 | - printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make 32 | - chmod +x $(npm config get prefix)/bin/elm-make 33 | 34 | script: 35 | - bash tests/run-tests.sh 36 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Main.elm: -------------------------------------------------------------------------------- 1 | port module Main exposing (..) 2 | 3 | import Basics exposing (..) 4 | import Task exposing (..) 5 | import Test exposing (..) 6 | import Platform.Cmd exposing (Cmd) 7 | import Json.Decode exposing (Value) 8 | import Test.Runner.Node exposing (run, TestProgram) 9 | import Test.Array as Array 10 | import Test.Basics as Basics 11 | import Test.Bitwise as Bitwise 12 | import Test.Char as Char 13 | import Test.CodeGen as CodeGen 14 | import Test.Dict as Dict 15 | import Test.Maybe as Maybe 16 | import Test.Equality as Equality 17 | import Test.Json as Json 18 | import Test.List as List 19 | import Test.Result as Result 20 | import Test.Set as Set 21 | import Test.String as String 22 | import Test.Regex as Regex 23 | 24 | 25 | tests : Test 26 | tests = 27 | describe "Elm Standard Library Tests" 28 | [ Array.tests 29 | , Basics.tests 30 | , Bitwise.tests 31 | , Char.tests 32 | , CodeGen.tests 33 | , Dict.tests 34 | , Equality.tests 35 | , Json.tests 36 | , List.tests 37 | , Result.tests 38 | , Set.tests 39 | , String.tests 40 | , Regex.tests 41 | , Maybe.tests 42 | ] 43 | 44 | 45 | main : TestProgram 46 | main = 47 | run emit tests 48 | 49 | 50 | port emit : ( String, Value ) -> Cmd msg 51 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Set.elm: -------------------------------------------------------------------------------- 1 | module Test.Set exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Set 5 | import Set exposing (Set) 6 | import List 7 | import Test exposing (..) 8 | import Expect 9 | 10 | 11 | set : Set Int 12 | set = 13 | Set.fromList <| List.range 1 100 14 | 15 | 16 | setPart1 : Set Int 17 | setPart1 = 18 | Set.fromList <| List.range 1 50 19 | 20 | 21 | setPart2 : Set Int 22 | setPart2 = 23 | Set.fromList <| List.range 51 100 24 | 25 | 26 | pred : Int -> Bool 27 | pred x = 28 | x <= 50 29 | 30 | 31 | tests : Test 32 | tests = 33 | let 34 | queryTests = 35 | describe "query Tests" 36 | [ test "size of set of 100 elements" <| 37 | \() -> Expect.equal 100 (Set.size set) 38 | ] 39 | 40 | filterTests = 41 | describe "filter Tests" 42 | [ test "Simple filter" <| 43 | \() -> Expect.equal setPart1 <| Set.filter pred set 44 | ] 45 | 46 | partitionTests = 47 | describe "partition Tests" 48 | [ test "Simple partition" <| 49 | \() -> Expect.equal ( setPart1, setPart2 ) <| Set.partition pred set 50 | ] 51 | in 52 | describe "Set Tests" [ queryTests, partitionTests, filterTests ] 53 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/properties-vs-attributes.md: -------------------------------------------------------------------------------- 1 | # Properties vs. Attributes 2 | 3 | When you are working with HTML, you can have DOM nodes like `
`. And you can add *attributes* to those DOM nodes, like ``. 4 | 5 | When you are creating DOM nodes in JavaScript, there are two ways to add attributes like this: 6 | 7 | 1. **Attributes** — You can use the `setAttribute` function. So adding a class attribute would look like this: `domNode.setAttribute('class', 'user-info')`. 8 | 9 | 2. **Properties** — JavaScript often exposes an alternate way to set these attributes. Another way to add a class attribute would be like this: `domNode.className = 'user-info'` 10 | 11 | Notice that the attribute is called `class` but the property is called `className`. This is because `class` is a reserved word in JavaScript. Point is, **attributes and properties do not always match up.** 12 | 13 | It is actually a bit crazier than that though. **Sometimes an attribute exists, but there is no corresponding property.** For example, as of this writing the `webkit-playsinline` can be added with `setAttribute`, but there is no corresponding property. And with SVG, you cannot use properties at all, you must to use `setAttributeNS` for everything. 14 | 15 | With all the corner cases here, it makes sense to have access to both approaches. -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/src/Html/Keyed.elm: -------------------------------------------------------------------------------- 1 | module Html.Keyed exposing 2 | ( node 3 | , ol 4 | , ul 5 | ) 6 | {-| A keyed node helps optimize cases where children are getting added, moved, 7 | removed, etc. Common examples include: 8 | 9 | - The user can delete items from a list. 10 | - The user can create new items in a list. 11 | - You can sort a list based on name or date or whatever. 12 | 13 | When you use a keyed node, every child is paired with a string identifier. This 14 | makes it possible for the underlying diffing algorithm to reuse nodes more 15 | efficiently. 16 | 17 | # Keyed Nodes 18 | @docs node 19 | 20 | # Commonly Keyed Nodes 21 | @docs ol, ul 22 | -} 23 | 24 | 25 | import Html exposing (Attribute, Html) 26 | import VirtualDom 27 | 28 | 29 | {-| Works just like `Html.node`, but you add a unique identifier to each child 30 | node. You want this when you have a list of nodes that is changing: adding 31 | nodes, removing nodes, etc. In these cases, the unique identifiers help make 32 | the DOM modifications more efficient. 33 | -} 34 | node : String -> List (Attribute msg) -> List ( String, Html msg ) -> Html msg 35 | node = 36 | VirtualDom.keyedNode 37 | 38 | 39 | {-|-} 40 | ol : List (Attribute msg) -> List ( String, Html msg ) -> Html msg 41 | ol = 42 | node "ol" 43 | 44 | 45 | {-|-} 46 | ul : List (Attribute msg) -> List ( String, Html msg ) -> Html msg 47 | ul = 48 | node "ul" 49 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Equality.elm: -------------------------------------------------------------------------------- 1 | module Test.Equality exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Maybe exposing (..) 5 | import Test exposing (..) 6 | import Expect 7 | 8 | 9 | type Different 10 | = A String 11 | | B (List Int) 12 | 13 | 14 | tests : Test 15 | tests = 16 | let 17 | diffTests = 18 | describe "ADT equality" 19 | [ test "As eq" <| \() -> Expect.equal True (A "a" == A "a") 20 | , test "Bs eq" <| \() -> Expect.equal True (B [ 1 ] == B [ 1 ]) 21 | , test "A left neq" <| \() -> Expect.equal True (A "a" /= B [ 1 ]) 22 | , test "A left neq" <| \() -> Expect.equal True (B [ 1 ] /= A "a") 23 | ] 24 | 25 | recordTests = 26 | describe "Record equality" 27 | [ test "empty same" <| \() -> Expect.equal True ({} == {}) 28 | , test "ctor same" <| \() -> Expect.equal True ({ field = Just 3 } == { field = Just 3 }) 29 | , test "ctor same, special case" <| \() -> Expect.equal True ({ ctor = Just 3 } == { ctor = Just 3 }) 30 | , test "ctor diff" <| \() -> Expect.equal True ({ field = Just 3 } /= { field = Nothing }) 31 | , test "ctor diff, special case" <| \() -> Expect.equal True ({ ctor = Just 3 } /= { ctor = Nothing }) 32 | ] 33 | in 34 | describe "Equality Tests" [ diffTests, recordTests ] 35 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Platform/Sub.elm: -------------------------------------------------------------------------------- 1 | module Platform.Sub exposing 2 | ( Sub 3 | , map 4 | , batch 5 | , none 6 | ) 7 | 8 | {-| 9 | 10 | @docs Sub, map, batch, none 11 | -} 12 | 13 | import Native.Platform 14 | 15 | 16 | {-| A subscription is a way of telling Elm, “Hey, let me know if anything 17 | interesting happens over there!” So if you want to listen for messages on a web 18 | socket, you would tell Elm to create a subscription. If you want to get clock 19 | ticks, you would tell Elm to subscribe to that. The cool thing here is that 20 | this means *Elm* manages all the details of subscriptions instead of *you*. 21 | So if a web socket goes down, *you* do not need to manually reconnect with an 22 | exponential backoff strategy, *Elm* does this all for you behind the scenes! 23 | 24 | Every `Sub` specifies (1) which effects you need access to and (2) the type of 25 | messages that will come back into your application. 26 | 27 | **Note:** Do not worry if this seems confusing at first! As with every Elm user 28 | ever, subscriptions will make more sense as you work through [the Elm Architecture 29 | Tutorial](http://guide.elm-lang.org/architecture/index.html) and see how they fit 30 | into a real application! 31 | -} 32 | type Sub msg = Sub 33 | 34 | 35 | {-|-} 36 | map : (a -> msg) -> Sub a -> Sub msg 37 | map = 38 | Native.Platform.map 39 | 40 | 41 | {-|-} 42 | batch : List (Sub msg) -> Sub msg 43 | batch = 44 | Native.Platform.batch 45 | 46 | 47 | {-|-} 48 | none : Sub msg 49 | none = 50 | batch [] 51 | 52 | 53 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Tuple.elm: -------------------------------------------------------------------------------- 1 | module Tuple exposing 2 | ( first, second 3 | , mapFirst, mapSecond 4 | ) 5 | 6 | {-| Some helpers for working with 2-tuples. 7 | 8 | **Note:** For larger chunks of data, it is best to switch to using records. So 9 | instead of representing a 3D point as `(3,4,5)` and wondering why there are no 10 | helper functions, represent it as `{ x = 3, y = 4, z = 5 }` and use all the 11 | built-in syntax for records. 12 | 13 | @docs first, second, mapFirst, mapSecond 14 | 15 | -} 16 | 17 | 18 | 19 | {-| Extract the first value from a tuple. 20 | 21 | first (3, 4) == 3 22 | first ("john", "doe") == "john" 23 | -} 24 | first : (a1, a2) -> a1 25 | first (x,_) = 26 | x 27 | 28 | 29 | {-| Extract the second value from a tuple. 30 | 31 | second (3, 4) == 4 32 | second ("john", "doe") == "doe" 33 | -} 34 | second : (a1, a2) -> a2 35 | second (_,y) = 36 | y 37 | 38 | 39 | {-| Transform the first value in a tuple. 40 | 41 | import String 42 | 43 | mapFirst String.reverse ("stressed", 16) == ("desserts", 16) 44 | mapFirst String.length ("stressed", 16) == (8, 16) 45 | -} 46 | mapFirst : (a -> b) -> (a, a2) -> (b, a2) 47 | mapFirst func (x,y) = 48 | (func x, y) 49 | 50 | 51 | {-| Transform the second value in a tuple. 52 | 53 | import String 54 | 55 | mapSecond sqrt ("stressed", 16) == ("stressed", 4) 56 | mapSecond (\x -> x + 1) ("stressed", 16) == ("stressed", 17) 57 | -} 58 | mapSecond : (a -> b) -> (a1, a) -> (a1, b) 59 | mapSecond func (x,y) = 60 | (x, func y) 61 | 62 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, NoRedInk 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of elm-decode-pipeline nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-present, Evan Czaplicki 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Evan Czaplicki nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/README.md: -------------------------------------------------------------------------------- 1 | # HTTP in Elm 2 | 3 | Make HTTP requests in Elm. 4 | 5 | ```elm 6 | import Http 7 | import Json.Decode as Decode 8 | 9 | 10 | -- GET A STRING 11 | 12 | getWarAndPeace : Http.Request String 13 | getWarAndPeace = 14 | Http.getString "https://example.com/books/war-and-peace" 15 | 16 | 17 | -- GET JSON 18 | 19 | getMetadata : Http.Request Metadata 20 | getMetadata = 21 | Http.get "https://example.com/books/war-and-peace/metadata" decodeMetadata 22 | 23 | type alias Metadata = 24 | { author : String 25 | , pages : Int 26 | } 27 | 28 | decodeMetadata : Decode.Decoder Metadata 29 | decodeMetadata = 30 | Decode.map2 Metadata 31 | (Decode.field "author" Decode.string) 32 | (Decode.field "pages" Decode.int) 33 | 34 | 35 | -- SEND REQUESTS 36 | 37 | type Msg 38 | = LoadMetadata (Result Http.Error Metadata) 39 | 40 | send : Cmd Msg 41 | send = 42 | Http.send LoadMetadata getMetadata 43 | ``` 44 | 45 | 46 | ## Examples 47 | 48 | - GET requests - [demo and code](http://elm-lang.org/examples/http) 49 | - Download progress - [demo](https://hirafuji.com.br/elm/http-progress-example/) and [code](https://gist.github.com/pablohirafuji/fa373d07c42016756d5bca28962008c4) 50 | 51 | 52 | ## Learn More 53 | 54 | To understand how HTTP works in Elm, check out: 55 | 56 | - [The HTTP example in the guide](https://guide.elm-lang.org/architecture/effects/http.html) to see a simple usage with some explanation. 57 | - [The Elm Architecture](https://guide.elm-lang.org/architecture/) to understand how HTTP fits into Elm in a more complete way. This will explain concepts like `Cmd` and `Sub` that appear in this package. 58 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present, Evan Czaplicki 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Evan Czaplicki nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present, Evan Czaplicki 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Evan Czaplicki nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-present, Evan Czaplicki 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Evan Czaplicki nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/html/2.0.0/src/Html/Lazy.elm: -------------------------------------------------------------------------------- 1 | module Html.Lazy exposing 2 | ( lazy, lazy2, lazy3 3 | ) 4 | 5 | {-| Since all Elm functions are pure we have a guarantee that the same input 6 | will always result in the same output. This module gives us tools to be lazy 7 | about building `Html` that utilize this fact. 8 | 9 | Rather than immediately applying functions to their arguments, the `lazy` 10 | functions just bundle the function and arguments up for later. When diffing 11 | the old and new virtual DOM, it checks to see if all the arguments are equal. 12 | If so, it skips calling the function! 13 | 14 | This is a really cheap test and often makes things a lot faster, but definitely 15 | benchmark to be sure! 16 | 17 | @docs lazy, lazy2, lazy3 18 | -} 19 | 20 | import Html exposing (Html) 21 | import VirtualDom 22 | 23 | 24 | {-| A performance optimization that delays the building of virtual DOM nodes. 25 | 26 | Calling `(view model)` will definitely build some virtual DOM, perhaps a lot of 27 | it. Calling `(lazy view model)` delays the call until later. During diffing, we 28 | can check to see if `model` is referentially equal to the previous value used, 29 | and if so, we just stop. No need to build up the tree structure and diff it, 30 | we know if the input to `view` is the same, the output must be the same! 31 | -} 32 | lazy : (a -> Html msg) -> a -> Html msg 33 | lazy = 34 | VirtualDom.lazy 35 | 36 | 37 | {-| Same as `lazy` but checks on two arguments. 38 | -} 39 | lazy2 : (a -> b -> Html msg) -> a -> b -> Html msg 40 | lazy2 = 41 | VirtualDom.lazy2 42 | 43 | 44 | {-| Same as `lazy` but checks on three arguments. 45 | -} 46 | lazy3 : (a -> b -> c -> Html msg) -> a -> b -> c -> Html msg 47 | lazy3 = 48 | VirtualDom.lazy3 49 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/http/1.0.0/rate-limit.md: -------------------------------------------------------------------------------- 1 | ## Custom Rate-Limiting Strategies 2 | 3 | This package has `Http.RateLimit` which helps you rate-limit the HTTP requests you make. Instead of sending one request per keystroke, you filter it down because not all requests are important. 4 | 5 | The `Http.RateLimit` module comes with a `debounce` strategy that covers the common case, but you may want to define a custom strategy with other characteristics. Maybe you want to send the first request. Maybe you want to send when the previous request is done instead of using timers. Etc. 6 | 7 | If so, you can define a custom strategy with `Http.RateLimit.customStrategy`. For example, you would define `throttle` like this: 8 | 9 | ```elm 10 | import Http.RateLimit as Limit 11 | 12 | throttle : Time -> Limit.Strategy 13 | throttle ms = 14 | Limit.customStrategy <| \timeNow event state -> 15 | case event of 16 | Limit.New _ -> 17 | -- wait after a new request 18 | [ Limit.WakeUpIn ms ] 19 | 20 | Limit.Done _ -> 21 | -- we do not care when requests finish 22 | [] 23 | 24 | Limit.WakeUp -> 25 | case state.next of 26 | Nothing -> 27 | -- do nothing if there is no pending request 28 | [] 29 | 30 | Just req -> 31 | -- send if enough time has passed since the previous request 32 | case state.prev of 33 | Nothing -> 34 | [ Limit.Send req.id ] 35 | 36 | Just prev -> 37 | if timeNow - prev.time >= ms then [ Limit.Send req.id ] else [] 38 | ``` 39 | 40 | It would be nice to have some useful strategies defined in a separate package so folks can experiment and find names and implementations that work well for specific scenarios. -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.sovmedcare.farm_stats_tw', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.sovmedcare.farm_stats_tw', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Platform/Cmd.elm: -------------------------------------------------------------------------------- 1 | module Platform.Cmd exposing 2 | ( Cmd 3 | , map 4 | , batch 5 | , none 6 | , (!) 7 | ) 8 | 9 | {-| 10 | 11 | # Effects 12 | 13 | Elm has **managed effects**, meaning that things like HTTP requests or writing 14 | to disk are all treated as *data* in Elm. When this data is given to the Elm 15 | runtime system, it can do some “query optimization” before actually performing 16 | the effect. Perhaps unexpectedly, this managed effects idea is the heart of why 17 | Elm is so nice for testing, reuse, reproducibility, etc. 18 | 19 | There are two kinds of managed effects you will use in your programs: commands 20 | and subscriptions. 21 | 22 | @docs Cmd, map, batch, none, (!) 23 | 24 | -} 25 | 26 | import Native.Platform 27 | 28 | 29 | {-| A command is a way of telling Elm, “Hey, I want you to do this thing!” 30 | So if you want to send an HTTP request, you would need to command Elm to do it. 31 | Or if you wanted to ask for geolocation, you would need to command Elm to go 32 | get it. 33 | 34 | Every `Cmd` specifies (1) which effects you need access to and (2) the type of 35 | messages that will come back into your application. 36 | 37 | **Note:** Do not worry if this seems confusing at first! As with every Elm user 38 | ever, commands will make more sense as you work through [the Elm Architecture 39 | Tutorial](http://guide.elm-lang.org/architecture/index.html) and see how they 40 | fit into a real application! 41 | -} 42 | type Cmd msg = Cmd 43 | 44 | 45 | {-|-} 46 | map : (a -> msg) -> Cmd a -> Cmd msg 47 | map = 48 | Native.Platform.map 49 | 50 | 51 | {-|-} 52 | batch : List (Cmd msg) -> Cmd msg 53 | batch = 54 | Native.Platform.batch 55 | 56 | 57 | {-|-} 58 | none : Cmd msg 59 | none = 60 | batch [] 61 | 62 | 63 | {-|-} 64 | (!) : model -> List (Cmd msg) -> (model, Cmd msg) 65 | (!) model commands = 66 | (model, batch commands) 67 | 68 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Purple Train 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.6 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 22 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UIAppFonts 41 | 42 | HK Compakt_bold.otf 43 | HK Compakt.otf 44 | Roboto Condensed.ttf 45 | 46 | UILaunchStoryboardName 47 | LaunchScreen 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UIStatusBarStyle 53 | UIStatusBarStyleLightContent 54 | UISupportedInterfaceOrientations 55 | 56 | UIInterfaceOrientationPortrait 57 | 58 | UIViewControllerBasedStatusBarAppearance 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /init-push-notifications.ios.js: -------------------------------------------------------------------------------- 1 | const { 2 | Alert, 3 | AppRegistry, 4 | AsyncStorage, 5 | PushNotificationIOS 6 | } = require('react-native') 7 | 8 | const upsertInstallation = (deviceToken, homeStopId) => { 9 | const endpoint = `https://farm_stats_tw.app.com/api/v2/installations/${deviceToken}` 10 | const params = { 11 | method: 'PUT', 12 | headers: { 13 | 'Content-Type': 'application/json', 14 | Accept: 'application/json' 15 | } 16 | } 17 | params.body = JSON.stringify({ 18 | home_stop_id: homeStopId, 19 | operating_system: 'ios', 20 | push_notifications_enabled: true 21 | }) 22 | 23 | fetch(endpoint, params).then(() => {}) 24 | } 25 | 26 | const _onRegistered = (elmApp, deviceToken) => { 27 | AsyncStorage.getItem('stop').then(stop => { 28 | if (stop) { 29 | upsertInstallation(deviceToken, stop) 30 | } 31 | }) 32 | 33 | // Store token so we can upsert later, when user changes their stop 34 | AsyncStorage.setItem('deviceToken', deviceToken) 35 | elmApp.ports.deviceTokenChanged.send(deviceToken) 36 | } 37 | 38 | const promptForCancellationsNotifications = () => { 39 | Alert.alert( 40 | 'This is what it sounds like when trains cry', 41 | 'Purple Train can send you notifications when your trains are cancelled!', 42 | [ 43 | { text: 'Not Now' }, 44 | { text: 'Give Access', onPress: PushNotificationIOS.requestPermissions } 45 | ] 46 | ) 47 | } 48 | 49 | const promptKey = 'promptedForCancellationsNotifications' 50 | 51 | export default function (elmApp) { 52 | // TODO - where to remove event listener? 53 | PushNotificationIOS.addEventListener('register', token => 54 | _onRegistered(elmApp, token) 55 | ) 56 | 57 | AsyncStorage.getItem(promptKey).then(value => { 58 | if (!value) { 59 | AsyncStorage.setItem(promptKey, 'somevalue').then(() => { 60 | promptForCancellationsNotifications() 61 | }) 62 | } 63 | }) 64 | } 65 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Debug.elm: -------------------------------------------------------------------------------- 1 | module Debug exposing 2 | ( log 3 | , crash 4 | ) 5 | 6 | {-| This library is for investigating bugs or performance problems. It should 7 | *not* be used in production code. 8 | 9 | # Debugging 10 | @docs log, crash 11 | -} 12 | 13 | import Native.Debug 14 | 15 | 16 | {-| Log a tagged value on the developer console, and then return the value. 17 | 18 | 1 + log "number" 1 -- equals 2, logs "number: 1" 19 | length (log "start" []) -- equals 0, logs "start: []" 20 | 21 | Notice that `log` is not a pure function! It should *only* be used for 22 | investigating bugs or performance problems. 23 | -} 24 | log : String -> a -> a 25 | log = 26 | Native.Debug.log 27 | 28 | 29 | {-| Crash the program with an error message. This is an uncatchable error, 30 | intended for code that is soon-to-be-implemented. For example, if you are 31 | working with a large ADT and have partially completed a case expression, it may 32 | make sense to do this: 33 | 34 | type Entity = Ship | Fish | Captain | Seagull 35 | 36 | drawEntity entity = 37 | case entity of 38 | Ship -> 39 | ... 40 | 41 | Fish -> 42 | ... 43 | 44 | _ -> 45 | Debug.crash "TODO" 46 | 47 | The Elm compiler recognizes each `Debug.crash` and when you run into it at 48 | runtime, the error will point to the corresponding module name and line number. 49 | For `case` expressions that ends with a wildcard pattern and a crash, it will 50 | also show the value that snuck through. In our example, that'd be `Captain` or 51 | `Seagull`. 52 | 53 | **Use this if** you want to do some testing while you are partway through 54 | writing a function. 55 | 56 | **Do not use this if** you want to do some typical try-catch exception handling. 57 | Use the [`Maybe`](Maybe) or [`Result`](Result) libraries instead. 58 | -} 59 | crash : String -> a 60 | crash = 61 | Native.Debug.crash 62 | 63 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | # We fork some components by platform. 4 | .*/*[.]android.js 5 | 6 | # Ignore templates with `@flow` in header 7 | .*/local-cli/generator.* 8 | 9 | # Ignore malformed json 10 | .*/node_modules/y18n/test/.*\.json 11 | 12 | # Ignore the website subdir 13 | /website/.* 14 | 15 | # Ignore BUCK generated dirs 16 | /\.buckd/ 17 | 18 | # Ignore unexpected extra @providesModule 19 | .*/node_modules/commoner/test/source/widget/share.js 20 | 21 | # Ignore duplicate module providers 22 | # For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root 23 | .*/Libraries/react-native/React.js 24 | .*/Libraries/react-native/ReactNative.js 25 | .*/node_modules/jest-runtime/build/__tests__/.* 26 | 27 | [include] 28 | 29 | [libs] 30 | node_modules/react-native/Libraries/react-native/react-native-interface.js 31 | node_modules/react-native/flow 32 | flow/ 33 | 34 | [options] 35 | module.system=haste 36 | 37 | esproposal.class_static_fields=enable 38 | esproposal.class_instance_fields=enable 39 | 40 | experimental.strict_type_args=true 41 | 42 | munge_underscores=true 43 | 44 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 45 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 46 | 47 | suppress_type=$FlowIssue 48 | suppress_type=$FlowFixMe 49 | suppress_type=$FixMe 50 | 51 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 52 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 53 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 54 | 55 | unsafe.enable_getters_and_setters=true 56 | 57 | [version] 58 | ^0.33.0 59 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the core libraries 2 | 3 | Thanks helping with the development of Elm! This document describes the basic 4 | standards for opening pull requests and making the review process as smooth as 5 | possible. 6 | 7 | ## Ground rules 8 | 9 | * Always make pull requests minimal. If it can be split up, it should be split up. 10 | * Use style consistent with the file you are modifying. 11 | * Use descriptive titles for PRs 12 | * Provide all the necessary context for evaluation in the PR. 13 | If there are relevant issues or examples or discussions, add them. 14 | If things can be summarized, summarize them. The easiest PRs are ones 15 | that already address the reviewers questions and concerns. 16 | 17 | ## Documentation Fixes 18 | 19 | If you want to fix docs, just open a PR. This is super helpful! 20 | 21 | ## Bug Fixes 22 | 23 | If you find an issue or see one you want to work on, go for it! 24 | 25 | The best strategy is often to dive in. Asking for directions usually 26 | does not work. If someone knew the specifics and knew how how to fix 27 | it, it is likely they would have already sent the PR themselves! 28 | 29 | Also, be sure you are testing. 30 | 31 | ## Adding New Functions 32 | 33 | We are fairly conservative about adding new functions to core libraries. 34 | If you want to augment the `List` or `Array` library, we recommend creating 35 | small packages called `list-extras` or `array-extras` that have all the 36 | features you want. There are already several such packages maintained at 37 | the [Elm Community organization](https://github.com/elm-community) that 38 | welcome contributions in the form of pull requests. 39 | 40 | Long term, we will set up a process to review `*-extras` packages to move 41 | stuff into core. By going through packages, it will be much easier to assess 42 | whether a function is pleasant and useful in practice before committing to it 43 | in the core libraries. 44 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Json/Encode.elm: -------------------------------------------------------------------------------- 1 | module Json.Encode exposing 2 | ( Value 3 | , encode 4 | , string, int, float, bool, null 5 | , list, array 6 | , object 7 | ) 8 | 9 | {-| Library for turning Elm values into Json values. 10 | 11 | # Encoding 12 | @docs encode, Value 13 | 14 | # Primitives 15 | @docs string, int, float, bool, null 16 | 17 | # Arrays 18 | @docs list, array 19 | 20 | # Objects 21 | @docs object 22 | -} 23 | 24 | import Array exposing (Array) 25 | import Native.Json 26 | 27 | 28 | {-| Represents a JavaScript value. 29 | -} 30 | type Value = Value 31 | 32 | 33 | {-| Convert a `Value` into a prettified string. The first argument specifies 34 | the amount of indentation in the resulting string. 35 | 36 | person = 37 | object 38 | [ ("name", string "Tom") 39 | , ("age", int 42) 40 | ] 41 | 42 | compact = encode 0 person 43 | -- {"name":"Tom","age":42} 44 | 45 | readable = encode 4 person 46 | -- { 47 | -- "name": "Tom", 48 | -- "age": 42 49 | -- } 50 | -} 51 | encode : Int -> Value -> String 52 | encode = 53 | Native.Json.encode 54 | 55 | 56 | {-|-} 57 | string : String -> Value 58 | string = 59 | Native.Json.identity 60 | 61 | 62 | {-|-} 63 | int : Int -> Value 64 | int = 65 | Native.Json.identity 66 | 67 | 68 | {-| Encode a Float. `Infinity` and `NaN` are encoded as `null`. 69 | -} 70 | float : Float -> Value 71 | float = 72 | Native.Json.identity 73 | 74 | 75 | {-|-} 76 | bool : Bool -> Value 77 | bool = 78 | Native.Json.identity 79 | 80 | 81 | {-|-} 82 | null : Value 83 | null = 84 | Native.Json.encodeNull 85 | 86 | 87 | {-|-} 88 | object : List (String, Value) -> Value 89 | object = 90 | Native.Json.encodeObject 91 | 92 | 93 | {-|-} 94 | array : Array Value -> Value 95 | array = 96 | Native.Json.encodeArray 97 | 98 | 99 | {-|-} 100 | list : List Value -> Value 101 | list = 102 | Native.Json.encodeList 103 | -------------------------------------------------------------------------------- /src/Web.elm: -------------------------------------------------------------------------------- 1 | module Web exposing (..) 2 | 3 | import Html exposing (Html, Attribute, h1, div, text, input, button, program) 4 | import Html.Attributes exposing (..) 5 | import Html.Events exposing (onInput, onClick) 6 | import Model exposing (..) 7 | import Update exposing (..) 8 | import Message exposing (Msg(..)) 9 | import Subscription exposing (..) 10 | import Types exposing (..) 11 | -- VIEW 12 | view : Model -> Html Msg 13 | view model = div [] 14 | [ div [] [ text "果菜市價查詢" ] 15 | , input [ placeholder "請輸入蔬果名", onInput ChangeSearchInput ] [] 16 | , button [ onClick ClickSearch ] [ text "搜索" ] 17 | , div [ style [( "width", "800px" ), ( "display", "flex" ), ( "flex-wrap", "wrap" )]] 18 | [ row [ "交易日期", "作物名稱", "市場名稱", "平均價" ] Nothing 19 | , div [] (contentView model) 20 | ] 21 | ] 22 | 23 | row : List String -> Maybe Int -> Html Msg 24 | row titles index = 25 | let 26 | index_ = Maybe.withDefault 0 index 27 | in 28 | div [style [("width", "800px"), ("display", "flex"), getBGColor index_]] 29 | (List.map (\title -> div [style [("flex", "1")]] [text title]) titles) 30 | 31 | contentView : Model -> List (Html Msg) 32 | contentView model = 33 | case List.length model.data of 34 | 0 -> if model.searched 35 | then List.singleton emptyView 36 | else [] 37 | _ -> 38 | List.indexedMap (,) model.data 39 | |> List.map (\(index, info) -> 40 | let titles = [info.tradeDate, info.cropName, info.marketName, toString (round (info.avgPrice * 0.6))] 41 | in row titles (Just index) 42 | ) 43 | 44 | emptyView : Html Msg 45 | emptyView = div [] [text "查無資料"] 46 | 47 | getBGColor : Int -> (String, String) 48 | getBGColor index = 49 | if (index % 2) == 0 50 | then ("background-color", "white") 51 | else ("background-color", "#81dde8") 52 | 53 | main : Program Never Model Msg 54 | main = program 55 | { init = init 56 | , view = view 57 | , update = update 58 | , subscriptions = subscriptions 59 | } -------------------------------------------------------------------------------- /ios/FarmStatsTW/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/src/VirtualDom/Report.elm: -------------------------------------------------------------------------------- 1 | module VirtualDom.Report exposing 2 | ( Report(..) 3 | , Change(..) 4 | , TagChanges 5 | , emptyTagChanges 6 | , hasTagChanges 7 | , Status(..), evaluate 8 | ) 9 | 10 | 11 | 12 | -- REPORTS 13 | 14 | 15 | type Report 16 | = CorruptHistory 17 | | VersionChanged String String 18 | | MessageChanged String String 19 | | SomethingChanged (List Change) 20 | 21 | 22 | type Change 23 | = AliasChange String 24 | | UnionChange String TagChanges 25 | 26 | 27 | type alias TagChanges = 28 | { removed : List String 29 | , changed : List String 30 | , added : List String 31 | , argsMatch : Bool 32 | } 33 | 34 | 35 | emptyTagChanges : Bool -> TagChanges 36 | emptyTagChanges argsMatch = 37 | TagChanges [] [] [] argsMatch 38 | 39 | 40 | hasTagChanges : TagChanges -> Bool 41 | hasTagChanges tagChanges = 42 | tagChanges == TagChanges [] [] [] True 43 | 44 | 45 | type Status = Impossible | Risky | Fine 46 | 47 | 48 | evaluate : Report -> Status 49 | evaluate report = 50 | case report of 51 | CorruptHistory -> 52 | Impossible 53 | 54 | VersionChanged _ _ -> 55 | Impossible 56 | 57 | MessageChanged _ _ -> 58 | Impossible 59 | 60 | SomethingChanged changes -> 61 | worstCase Fine (List.map evaluateChange changes) 62 | 63 | 64 | worstCase : Status -> List Status -> Status 65 | worstCase status statusList = 66 | case statusList of 67 | [] -> 68 | status 69 | 70 | Impossible :: _ -> 71 | Impossible 72 | 73 | Risky :: rest -> 74 | worstCase Risky rest 75 | 76 | Fine :: rest -> 77 | worstCase status rest 78 | 79 | 80 | evaluateChange : Change -> Status 81 | evaluateChange change = 82 | case change of 83 | AliasChange _ -> 84 | Impossible 85 | 86 | UnionChange _ { removed, changed, added, argsMatch } -> 87 | if not argsMatch || some changed || some removed then 88 | Impossible 89 | 90 | else if some added then 91 | Risky 92 | 93 | else 94 | Fine 95 | 96 | 97 | some : List a -> Bool 98 | some list = 99 | not (List.isEmpty list) 100 | -------------------------------------------------------------------------------- /src/Update.elm: -------------------------------------------------------------------------------- 1 | module Update exposing (..) 2 | 3 | import Http 4 | import Json.Decode as Decode 5 | import Json.Decode.Pipeline exposing (decode, required) 6 | import Model exposing (Model) 7 | import Message exposing (..) 8 | import Types exposing (Info, PriceData, Response) 9 | import Api exposing (baseUrl) 10 | import Date.Format exposing (format) 11 | import Date 12 | 13 | update : Msg -> Model -> ( Model, Cmd Msg ) 14 | update msg model = 15 | case msg of 16 | NoOp -> ( model, Cmd.none ) 17 | ChangeSearchInput s -> ( { model | searchInput = s }, Cmd.none ) 18 | ClickSearch -> ( { model | searched = True }, sendRequest model.searchInput ) 19 | NewPriceData (Ok data) -> ( { model | data = data.docs, searched = False }, Cmd.none ) 20 | NewPriceData (Err _) -> ( model, Cmd.none ) 21 | 22 | getPriceData : String -> Http.Request Response 23 | getPriceData query = 24 | Http.get (baseUrl ++ "cropName=" ++ query) decodeResponse 25 | 26 | decodeResponse : Decode.Decoder Response 27 | decodeResponse = 28 | decode Response 29 | |> required "docs" (Decode.list decodePriceData) 30 | |> required "total" (Decode.int) 31 | |> required "limit" (Decode.int) 32 | |> required "page" (Decode.int) 33 | |> required "pages" (Decode.int) 34 | 35 | decodePriceData : Decode.Decoder Info 36 | decodePriceData = 37 | decode Info 38 | |> required "tradeDate" (Decode.map parseDate Decode.string) 39 | |> required "cropCode" (Decode.string) 40 | |> required "cropName" (Decode.string) 41 | |> required "marketCode" (Decode.string) 42 | |> required "marketName" (Decode.string) 43 | |> required "highPrice" (Decode.float) 44 | |> required "middlePrice" (Decode.float) 45 | |> required "lowPrice" (Decode.float) 46 | |> required "avgPrice" (Decode.float) 47 | |> required "tradeCount" (Decode.float) 48 | |> required "updated" (Decode.string) 49 | |> required "created" (Decode.string) 50 | 51 | parseDate : String -> String 52 | parseDate tradeDate = 53 | let date = 54 | case Date.fromString tradeDate of 55 | Ok d -> format "%Y/%m/%d" d 56 | Err e -> "" 57 | in date 58 | 59 | sendRequest : String -> Cmd Msg 60 | sendRequest query = Http.send NewPriceData (getPriceData query) 61 | -------------------------------------------------------------------------------- /ios/FarmStatsTWTests/FarmStatsTWTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "RCTLog.h" 14 | #import "RCTRootView.h" 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface FarmStatsTWTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation FarmStatsTWTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Bitwise.elm: -------------------------------------------------------------------------------- 1 | module Bitwise exposing 2 | ( and, or, xor, complement 3 | , shiftLeftBy, shiftRightBy, shiftRightZfBy 4 | ) 5 | 6 | {-| Library for [bitwise operations](http://en.wikipedia.org/wiki/Bitwise_operation). 7 | 8 | # Basic Operations 9 | @docs and, or, xor, complement 10 | 11 | # Bit Shifts 12 | @docs shiftLeftBy, shiftRightBy, shiftRightZfBy 13 | -} 14 | 15 | import Native.Bitwise 16 | 17 | 18 | {-| Bitwise AND 19 | -} 20 | and : Int -> Int -> Int 21 | and = 22 | Native.Bitwise.and 23 | 24 | 25 | {-| Bitwise OR 26 | -} 27 | or : Int -> Int -> Int 28 | or = 29 | Native.Bitwise.or 30 | 31 | 32 | {-| Bitwise XOR 33 | -} 34 | xor : Int -> Int -> Int 35 | xor = 36 | Native.Bitwise.xor 37 | 38 | 39 | {-| Flip each bit individually, often called bitwise NOT 40 | -} 41 | complement : Int -> Int 42 | complement = 43 | Native.Bitwise.complement 44 | 45 | 46 | {-| Shift bits to the left by a given offset, filling new bits with zeros. 47 | This can be used to multiply numbers by powers of two. 48 | 49 | shiftLeftBy 1 5 == 10 50 | shiftLeftBy 5 1 == 32 51 | -} 52 | shiftLeftBy : Int -> Int -> Int 53 | shiftLeftBy = 54 | Native.Bitwise.shiftLeftBy 55 | 56 | 57 | {-| Shift bits to the right by a given offset, filling new bits with 58 | whatever is the topmost bit. This can be used to divide numbers by powers of two. 59 | 60 | shiftRightBy 1 32 == 16 61 | shiftRightBy 2 32 == 8 62 | shiftRightBy 1 -32 == -16 63 | 64 | This is called an [arithmetic right shift][ars], often written (>>), and 65 | sometimes called a sign-propagating right shift because it fills empty spots 66 | with copies of the highest bit. 67 | 68 | [ars]: http://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift 69 | -} 70 | shiftRightBy : Int -> Int -> Int 71 | shiftRightBy = 72 | Native.Bitwise.shiftRightBy 73 | 74 | 75 | {-| Shift bits to the right by a given offset, filling new bits with zeros. 76 | 77 | shiftRightZfBy 1 32 == 16 78 | shiftRightZfBy 2 32 == 8 79 | shiftRightZfBy 1 -32 == 2147483632 80 | 81 | This is called an [logical right shift][lrs], often written (>>>), and 82 | sometimes called a zero-fill right shift because it fills empty spots with 83 | zeros. 84 | 85 | [lrs]: http://en.wikipedia.org/wiki/Bitwise_operation#Logical_shift 86 | -} 87 | shiftRightZfBy : Int -> Int -> Int 88 | shiftRightZfBy = 89 | Native.Bitwise.shiftRightZfBy 90 | 91 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Char.elm: -------------------------------------------------------------------------------- 1 | module Char exposing 2 | ( isUpper, isLower, isDigit, isOctDigit, isHexDigit 3 | , toUpper, toLower, toLocaleUpper, toLocaleLower 4 | , KeyCode, toCode, fromCode 5 | ) 6 | 7 | {-| Functions for working with characters. Character literals are enclosed in 8 | `'a'` pair of single quotes. 9 | 10 | # Classification 11 | @docs isUpper, isLower, isDigit, isOctDigit, isHexDigit 12 | 13 | # Conversion 14 | @docs toUpper, toLower, toLocaleUpper, toLocaleLower 15 | 16 | # Key Codes 17 | @docs KeyCode, toCode, fromCode 18 | 19 | -} 20 | 21 | import Native.Char 22 | import Basics exposing ((&&), (||), (>=), (<=)) 23 | 24 | 25 | isBetween : Char -> Char -> Char -> Bool 26 | isBetween low high char = 27 | let code = toCode char 28 | in 29 | (code >= toCode low) && (code <= toCode high) 30 | 31 | 32 | {-| True for upper case ASCII letters. -} 33 | isUpper : Char -> Bool 34 | isUpper = 35 | isBetween 'A' 'Z' 36 | 37 | 38 | {-| True for lower case ASCII letters. -} 39 | isLower : Char -> Bool 40 | isLower = 41 | isBetween 'a' 'z' 42 | 43 | 44 | {-| True for ASCII digits `[0-9]`. -} 45 | isDigit : Char -> Bool 46 | isDigit = 47 | isBetween '0' '9' 48 | 49 | 50 | {-| True for ASCII octal digits `[0-7]`. -} 51 | isOctDigit : Char -> Bool 52 | isOctDigit = 53 | isBetween '0' '7' 54 | 55 | 56 | {-| True for ASCII hexadecimal digits `[0-9a-fA-F]`. -} 57 | isHexDigit : Char -> Bool 58 | isHexDigit char = 59 | isDigit char || isBetween 'a' 'f' char || isBetween 'A' 'F' char 60 | 61 | 62 | {-| Convert to upper case. -} 63 | toUpper : Char -> Char 64 | toUpper = 65 | Native.Char.toUpper 66 | 67 | 68 | {-| Convert to lower case. -} 69 | toLower : Char -> Char 70 | toLower = 71 | Native.Char.toLower 72 | 73 | 74 | {-| Convert to upper case, according to any locale-specific case mappings. -} 75 | toLocaleUpper : Char -> Char 76 | toLocaleUpper = 77 | Native.Char.toLocaleUpper 78 | 79 | 80 | {-| Convert to lower case, according to any locale-specific case mappings. -} 81 | toLocaleLower : Char -> Char 82 | toLocaleLower = 83 | Native.Char.toLocaleLower 84 | 85 | 86 | {-| Keyboard keys can be represented as integers. These are called *key codes*. 87 | You can use [`toCode`](#toCode) and [`fromCode`](#fromCode) to convert between 88 | key codes and characters. 89 | -} 90 | type alias KeyCode = Int 91 | 92 | 93 | {-| Convert to key code. 94 | -} 95 | toCode : Char -> KeyCode 96 | toCode = 97 | Native.Char.toCode 98 | 99 | 100 | {-| Convert from key code. -} 101 | fromCode : KeyCode -> Char 102 | fromCode = 103 | Native.Char.fromCode 104 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Regex.elm: -------------------------------------------------------------------------------- 1 | module Test.Regex exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Regex exposing (..) 5 | import Test exposing (..) 6 | import Expect 7 | 8 | 9 | tests : Test 10 | tests = 11 | let 12 | simpleTests = 13 | describe "Simple Stuff" 14 | [ test "split All" <| \() -> Expect.equal [ "a", "b" ] (split All (regex ",") "a,b") 15 | , test "split" <| \() -> Expect.equal [ "a", "b,c" ] (split (AtMost 1) (regex ",") "a,b,c") 16 | , test "split idempotent" <| 17 | \() -> 18 | let 19 | findComma = 20 | regex "," 21 | in 22 | Expect.equal 23 | (split (AtMost 1) findComma "a,b,c,d,e") 24 | (split (AtMost 1) findComma "a,b,c,d,e") 25 | , test "find All" <| 26 | \() -> 27 | Expect.equal 28 | ([ Match "a" [] 0 1, Match "b" [] 1 2 ]) 29 | (find All (regex ".") "ab") 30 | , test "find All" <| 31 | \() -> 32 | Expect.equal 33 | ([ Match "" [] 0 1 ]) 34 | (find All (regex ".*") "") 35 | , test "replace AtMost 0" <| 36 | \() -> 37 | Expect.equal "The quick brown fox" 38 | (replace (AtMost 0) (regex "[aeiou]") (\_ -> "") "The quick brown fox") 39 | , test "replace AtMost 1" <| 40 | \() -> 41 | Expect.equal "Th quick brown fox" 42 | (replace (AtMost 1) (regex "[aeiou]") (\_ -> "") "The quick brown fox") 43 | , test "replace AtMost 2" <| 44 | \() -> 45 | Expect.equal "Th qick brown fox" 46 | (replace (AtMost 2) (regex "[aeiou]") (\_ -> "") "The quick brown fox") 47 | , test "replace All" <| 48 | \() -> 49 | Expect.equal "Th qck brwn fx" 50 | (replace All (regex "[aeiou]") (\_ -> "") "The quick brown fox") 51 | , test "replace using index" <| 52 | \() -> 53 | Expect.equal "a1b3c" 54 | (replace All (regex ",") (\match -> toString match.index) "a,b,c") 55 | ] 56 | in 57 | describe "Regex" [ simpleTests ] 58 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Result.elm: -------------------------------------------------------------------------------- 1 | module Test.Result exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Result 5 | import Result exposing (Result(..)) 6 | import String 7 | import Test exposing (..) 8 | import Expect 9 | 10 | 11 | isEven n = 12 | if n % 2 == 0 then 13 | Ok n 14 | else 15 | Err "number is odd" 16 | 17 | 18 | add3 a b c = 19 | a + b + c 20 | 21 | 22 | add4 a b c d = 23 | a + b + c + d 24 | 25 | 26 | add5 a b c d e = 27 | a + b + c + d + e 28 | 29 | 30 | tests : Test 31 | tests = 32 | let 33 | mapTests = 34 | describe "map Tests" 35 | [ test "map Ok" <| \() -> Expect.equal (Ok 3) (Result.map ((+) 1) (Ok 2)) 36 | , test "map Err" <| \() -> Expect.equal (Err "error") (Result.map ((+) 1) (Err "error")) 37 | ] 38 | 39 | mapNTests = 40 | describe "mapN Tests" 41 | [ test "map2 Ok" <| \() -> Expect.equal (Ok 3) (Result.map2 (+) (Ok 1) (Ok 2)) 42 | , test "map2 Err" <| \() -> Expect.equal (Err "x") (Result.map2 (+) (Ok 1) (Err "x")) 43 | , test "map3 Ok" <| \() -> Expect.equal (Ok 6) (Result.map3 add3 (Ok 1) (Ok 2) (Ok 3)) 44 | , test "map3 Err" <| \() -> Expect.equal (Err "x") (Result.map3 add3 (Ok 1) (Ok 2) (Err "x")) 45 | , test "map4 Ok" <| \() -> Expect.equal (Ok 10) (Result.map4 add4 (Ok 1) (Ok 2) (Ok 3) (Ok 4)) 46 | , test "map4 Err" <| \() -> Expect.equal (Err "x") (Result.map4 add4 (Ok 1) (Ok 2) (Ok 3) (Err "x")) 47 | , test "map5 Ok" <| \() -> Expect.equal (Ok 15) (Result.map5 add5 (Ok 1) (Ok 2) (Ok 3) (Ok 4) (Ok 5)) 48 | , test "map5 Err" <| \() -> Expect.equal (Err "x") (Result.map5 add5 (Ok 1) (Ok 2) (Ok 3) (Ok 4) (Err "x")) 49 | ] 50 | 51 | andThenTests = 52 | describe "andThen Tests" 53 | [ test "andThen Ok" <| \() -> Expect.equal (Ok 42) ((String.toInt "42") |> Result.andThen isEven) 54 | , test "andThen first Err" <| 55 | \() -> 56 | Expect.equal 57 | (Err "could not convert string '4.2' to an Int") 58 | (String.toInt "4.2" |> Result.andThen isEven) 59 | , test "andThen second Err" <| 60 | \() -> 61 | Expect.equal 62 | (Err "number is odd") 63 | (String.toInt "41" |> Result.andThen isEven) 64 | ] 65 | in 66 | describe "Result Tests" 67 | [ mapTests 68 | , mapNTests 69 | , andThenTests 70 | ] 71 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTBundleURLProvider.h" 13 | #import "RCTRootView.h" 14 | #import "RCTPushNotificationManager.h" 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 19 | { 20 | NSURL *jsCodeLocation; 21 | 22 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 23 | 24 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 25 | moduleName:@"FarmStatsTW" 26 | initialProperties:nil 27 | launchOptions:launchOptions]; 28 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 29 | 30 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 31 | UIViewController *rootViewController = [UIViewController new]; 32 | rootViewController.view = rootView; 33 | self.window.rootViewController = rootViewController; 34 | [self.window makeKeyAndVisible]; 35 | return YES; 36 | } 37 | 38 | // Required to register for notifications 39 | - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings 40 | { 41 | [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings]; 42 | } 43 | // Required for the register event. 44 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 45 | { 46 | [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; 47 | } 48 | // Required for the registrationError event. 49 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error 50 | { 51 | [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error]; 52 | } 53 | // Required for the notification event. 54 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification 55 | { 56 | [RCTPushNotificationManager didReceiveRemoteNotification:notification]; 57 | } 58 | // Required for the localNotification event. 59 | - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 60 | { 61 | [RCTPushNotificationManager didReceiveLocalNotification:notification]; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/List.js: -------------------------------------------------------------------------------- 1 | //import Native.Utils // 2 | 3 | var _elm_lang$core$Native_List = function() { 4 | 5 | var Nil = { ctor: '[]' }; 6 | 7 | function Cons(hd, tl) 8 | { 9 | return { ctor: '::', _0: hd, _1: tl }; 10 | } 11 | 12 | function fromArray(arr) 13 | { 14 | var out = Nil; 15 | for (var i = arr.length; i--; ) 16 | { 17 | out = Cons(arr[i], out); 18 | } 19 | return out; 20 | } 21 | 22 | function toArray(xs) 23 | { 24 | var out = []; 25 | while (xs.ctor !== '[]') 26 | { 27 | out.push(xs._0); 28 | xs = xs._1; 29 | } 30 | return out; 31 | } 32 | 33 | function foldr(f, b, xs) 34 | { 35 | var arr = toArray(xs); 36 | var acc = b; 37 | for (var i = arr.length; i--; ) 38 | { 39 | acc = A2(f, arr[i], acc); 40 | } 41 | return acc; 42 | } 43 | 44 | function map2(f, xs, ys) 45 | { 46 | var arr = []; 47 | while (xs.ctor !== '[]' && ys.ctor !== '[]') 48 | { 49 | arr.push(A2(f, xs._0, ys._0)); 50 | xs = xs._1; 51 | ys = ys._1; 52 | } 53 | return fromArray(arr); 54 | } 55 | 56 | function map3(f, xs, ys, zs) 57 | { 58 | var arr = []; 59 | while (xs.ctor !== '[]' && ys.ctor !== '[]' && zs.ctor !== '[]') 60 | { 61 | arr.push(A3(f, xs._0, ys._0, zs._0)); 62 | xs = xs._1; 63 | ys = ys._1; 64 | zs = zs._1; 65 | } 66 | return fromArray(arr); 67 | } 68 | 69 | function map4(f, ws, xs, ys, zs) 70 | { 71 | var arr = []; 72 | while ( ws.ctor !== '[]' 73 | && xs.ctor !== '[]' 74 | && ys.ctor !== '[]' 75 | && zs.ctor !== '[]') 76 | { 77 | arr.push(A4(f, ws._0, xs._0, ys._0, zs._0)); 78 | ws = ws._1; 79 | xs = xs._1; 80 | ys = ys._1; 81 | zs = zs._1; 82 | } 83 | return fromArray(arr); 84 | } 85 | 86 | function map5(f, vs, ws, xs, ys, zs) 87 | { 88 | var arr = []; 89 | while ( vs.ctor !== '[]' 90 | && ws.ctor !== '[]' 91 | && xs.ctor !== '[]' 92 | && ys.ctor !== '[]' 93 | && zs.ctor !== '[]') 94 | { 95 | arr.push(A5(f, vs._0, ws._0, xs._0, ys._0, zs._0)); 96 | vs = vs._1; 97 | ws = ws._1; 98 | xs = xs._1; 99 | ys = ys._1; 100 | zs = zs._1; 101 | } 102 | return fromArray(arr); 103 | } 104 | 105 | function sortBy(f, xs) 106 | { 107 | return fromArray(toArray(xs).sort(function(a, b) { 108 | return _elm_lang$core$Native_Utils.cmp(f(a), f(b)); 109 | })); 110 | } 111 | 112 | function sortWith(f, xs) 113 | { 114 | return fromArray(toArray(xs).sort(function(a, b) { 115 | var ord = f(a)(b).ctor; 116 | return ord === 'EQ' ? 0 : ord === 'LT' ? -1 : 1; 117 | })); 118 | } 119 | 120 | return { 121 | Nil: Nil, 122 | Cons: Cons, 123 | cons: F2(Cons), 124 | toArray: toArray, 125 | fromArray: fromArray, 126 | 127 | foldr: F3(foldr), 128 | 129 | map2: F3(map2), 130 | map3: F4(map3), 131 | map4: F5(map4), 132 | map5: F6(map5), 133 | sortBy: F2(sortBy), 134 | sortWith: F2(sortWith) 135 | }; 136 | 137 | }(); -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Basics.js: -------------------------------------------------------------------------------- 1 | //import Native.Utils // 2 | 3 | var _elm_lang$core$Native_Basics = function() { 4 | 5 | function div(a, b) 6 | { 7 | return (a / b) | 0; 8 | } 9 | function rem(a, b) 10 | { 11 | return a % b; 12 | } 13 | function mod(a, b) 14 | { 15 | if (b === 0) 16 | { 17 | throw new Error('Cannot perform mod 0. Division by zero error.'); 18 | } 19 | var r = a % b; 20 | var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r + b) : -mod(-a, -b)); 21 | 22 | return m === b ? 0 : m; 23 | } 24 | function logBase(base, n) 25 | { 26 | return Math.log(n) / Math.log(base); 27 | } 28 | function negate(n) 29 | { 30 | return -n; 31 | } 32 | function abs(n) 33 | { 34 | return n < 0 ? -n : n; 35 | } 36 | 37 | function min(a, b) 38 | { 39 | return _elm_lang$core$Native_Utils.cmp(a, b) < 0 ? a : b; 40 | } 41 | function max(a, b) 42 | { 43 | return _elm_lang$core$Native_Utils.cmp(a, b) > 0 ? a : b; 44 | } 45 | function clamp(lo, hi, n) 46 | { 47 | return _elm_lang$core$Native_Utils.cmp(n, lo) < 0 48 | ? lo 49 | : _elm_lang$core$Native_Utils.cmp(n, hi) > 0 50 | ? hi 51 | : n; 52 | } 53 | 54 | var ord = ['LT', 'EQ', 'GT']; 55 | 56 | function compare(x, y) 57 | { 58 | return { ctor: ord[_elm_lang$core$Native_Utils.cmp(x, y) + 1] }; 59 | } 60 | 61 | function xor(a, b) 62 | { 63 | return a !== b; 64 | } 65 | function not(b) 66 | { 67 | return !b; 68 | } 69 | function isInfinite(n) 70 | { 71 | return n === Infinity || n === -Infinity; 72 | } 73 | 74 | function truncate(n) 75 | { 76 | return n | 0; 77 | } 78 | 79 | function degrees(d) 80 | { 81 | return d * Math.PI / 180; 82 | } 83 | function turns(t) 84 | { 85 | return 2 * Math.PI * t; 86 | } 87 | function fromPolar(point) 88 | { 89 | var r = point._0; 90 | var t = point._1; 91 | return _elm_lang$core$Native_Utils.Tuple2(r * Math.cos(t), r * Math.sin(t)); 92 | } 93 | function toPolar(point) 94 | { 95 | var x = point._0; 96 | var y = point._1; 97 | return _elm_lang$core$Native_Utils.Tuple2(Math.sqrt(x * x + y * y), Math.atan2(y, x)); 98 | } 99 | 100 | return { 101 | div: F2(div), 102 | rem: F2(rem), 103 | mod: F2(mod), 104 | 105 | pi: Math.PI, 106 | e: Math.E, 107 | cos: Math.cos, 108 | sin: Math.sin, 109 | tan: Math.tan, 110 | acos: Math.acos, 111 | asin: Math.asin, 112 | atan: Math.atan, 113 | atan2: F2(Math.atan2), 114 | 115 | degrees: degrees, 116 | turns: turns, 117 | fromPolar: fromPolar, 118 | toPolar: toPolar, 119 | 120 | sqrt: Math.sqrt, 121 | logBase: F2(logBase), 122 | negate: negate, 123 | abs: abs, 124 | min: F2(min), 125 | max: F2(max), 126 | clamp: F3(clamp), 127 | compare: F2(compare), 128 | 129 | xor: F2(xor), 130 | not: not, 131 | 132 | truncate: truncate, 133 | ceiling: Math.ceil, 134 | floor: Math.floor, 135 | round: Math.round, 136 | toFloat: function(x) { return x; }, 137 | isNaN: isNaN, 138 | isInfinite: isInfinite 139 | }; 140 | 141 | }(); -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/TestCases/Lazy.elm: -------------------------------------------------------------------------------- 1 | module TestCases.Lazy where 2 | 3 | import VirtualDom exposing (Node, lazy) 4 | import ElmTest.Assertion exposing (assertEqual) 5 | import ElmTest.Test exposing (Test, suite, test) 6 | 7 | import TestHelpers exposing (renderDom, updateDom, unsafeRecordCallCount, unsafeQueryCallCount) 8 | 9 | renderRecord : { x: String, y: String } -> Node 10 | renderRecord r = 11 | VirtualDom.text <| "The values: " ++ r.x ++ ", " ++ r.y 12 | 13 | 14 | renderPrimitive : Int -> Node 15 | renderPrimitive x = 16 | VirtualDom.text <| "The value: " ++ (toString x) 17 | 18 | 19 | testLazyIdenticalRecord = 20 | test "isn't called again with identical record" <| 21 | let record = { x = "a", y = "b" } 22 | wrappedRender = unsafeRecordCallCount renderRecord 23 | v1 = renderDom <| lazy wrappedRender record 24 | v2 = updateDom v1 <| lazy wrappedRender record 25 | v3 = updateDom v2 <| lazy wrappedRender record 26 | in 27 | assertEqual 1 <| unsafeQueryCallCount wrappedRender 28 | 29 | 30 | testLazyIdenticalPrimitive = 31 | test "isn't called again with identical primitive" <| 32 | let wrappedRender = unsafeRecordCallCount renderPrimitive 33 | v1 = renderDom <| lazy wrappedRender 5 34 | v2 = updateDom v1 <| lazy wrappedRender 5 35 | v3 = updateDom v2 <| lazy wrappedRender 5 36 | in 37 | assertEqual 1 <| unsafeQueryCallCount wrappedRender 38 | 39 | 40 | testLazyRecordMutationOfIdenticalValue = 41 | test "isn't called again with record mutation of identical value" <| 42 | let record = { x = "a", y = "b" } 43 | wrappedRender = unsafeRecordCallCount renderRecord 44 | v1 = renderDom <| lazy wrappedRender record 45 | v2 = updateDom v1 <| lazy wrappedRender { record | x = "a" } 46 | v3 = updateDom v2 <| lazy wrappedRender { record | x = "a", y = "b" } 47 | in 48 | assertEqual 1 <| unsafeQueryCallCount wrappedRender 49 | 50 | 51 | testNotLazyDifferentRecord = 52 | test "is called again with an equivalent but different record" <| 53 | let wrappedRender = unsafeRecordCallCount renderRecord 54 | v1 = renderDom <| lazy wrappedRender { x = "a", y = "b" } 55 | v2 = updateDom v1 <| lazy wrappedRender { x = "a", y = "b" } 56 | v3 = updateDom v2 <| lazy wrappedRender { x = "a", y = "b" } 57 | in 58 | assertEqual 3 <| unsafeQueryCallCount wrappedRender 59 | 60 | 61 | tests : Test 62 | tests = 63 | suite 64 | "Lazy" 65 | [ 66 | testLazyIdenticalRecord, 67 | testLazyIdenticalPrimitive, 68 | -- Re-enable this test when core supports checking 69 | -- record update values for identity before copying: 70 | -- testLazyRecordMutationOfIdenticalValue, 71 | testNotLazyDifferentRecord 72 | ] 73 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/CodeGen.elm: -------------------------------------------------------------------------------- 1 | module Test.CodeGen exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Test exposing (..) 5 | import Expect 6 | import Maybe 7 | import Maybe exposing (..) 8 | 9 | 10 | type Wrapper a 11 | = Wrapper a 12 | 13 | 14 | caseUnderscore : Maybe number -> number 15 | caseUnderscore m_ = 16 | case m_ of 17 | Just x -> 18 | x 19 | 20 | Nothing -> 21 | 0 22 | 23 | 24 | patternUnderscore : number 25 | patternUnderscore = 26 | case Just 42 of 27 | Just x_ -> 28 | x_ 29 | 30 | Nothing -> 31 | 0 32 | 33 | 34 | letQualified : number 35 | letQualified = 36 | let 37 | (Wrapper x) = 38 | Wrapper 42 39 | in 40 | x 41 | 42 | 43 | caseQualified : number 44 | caseQualified = 45 | case Just 42 of 46 | Maybe.Just x -> 47 | x 48 | 49 | Nothing -> 50 | 0 51 | 52 | 53 | caseScope : String 54 | caseScope = 55 | case "Not this one!" of 56 | string -> 57 | case "Hi" of 58 | string -> 59 | string 60 | 61 | 62 | tests : Test 63 | tests = 64 | let 65 | -- We don't strictly speaking need annotations in this let-expression, 66 | -- but having these here exercises the parser to avoid regressions like 67 | -- https://github.com/elm-lang/elm-compiler/issues/1535 68 | underscores : Test 69 | underscores = 70 | describe "Underscores" 71 | [ test "case" <| \() -> Expect.equal 42 (caseUnderscore (Just 42)) 72 | , test "pattern" <| \() -> Expect.equal 42 patternUnderscore 73 | ] 74 | 75 | qualifiedPatterns : Test 76 | qualifiedPatterns = 77 | describe "Qualified Patterns" 78 | [ test "let" <| \() -> Expect.equal 42 letQualified 79 | , test "case" <| \() -> Expect.equal 42 caseQualified 80 | ] 81 | 82 | scope : Test 83 | scope = 84 | describe "Scoping" 85 | [ test "case" <| \() -> Expect.equal "Hi" caseScope ] 86 | 87 | hex : Test 88 | hex = 89 | describe "Hex" 90 | [ test "0xFFFFFFFF" <| 91 | \() -> 92 | 0xFFFFFFFF 93 | |> Expect.equal 4294967295 94 | , test "0xD066F00D" <| 95 | \() -> 96 | 0xD066F00D 97 | |> Expect.equal 3496407053 98 | , test "0x00" <| 99 | \() -> 100 | 0x00 101 | |> Expect.equal 0 102 | ] 103 | in 104 | describe "CodeGen" 105 | [ underscores 106 | , qualifiedPatterns 107 | , scope 108 | , hex 109 | ] 110 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/virtual-dom/2.0.4/src/VirtualDom/Helpers.elm: -------------------------------------------------------------------------------- 1 | module VirtualDom.Helpers exposing 2 | ( Node 3 | , text, node, div, span, a, h1 4 | , Property, property, attribute 5 | , class, id, href 6 | , style 7 | , on, onWithOptions, Options, defaultOptions 8 | , onClick 9 | , map 10 | , lazy, lazy2, lazy3 11 | , keyedNode 12 | ) 13 | 14 | 15 | import Json.Decode as Decode 16 | import Json.Encode as Encode 17 | import Native.VirtualDom 18 | 19 | 20 | type Node msg = Node 21 | 22 | 23 | node : String -> List (Property msg) -> List (Node msg) -> Node msg 24 | node = 25 | Native.VirtualDom.node 26 | 27 | 28 | text : String -> Node msg 29 | text = 30 | Native.VirtualDom.text 31 | 32 | 33 | div : List (Property msg) -> List (Node msg) -> Node msg 34 | div = 35 | node "div" 36 | 37 | 38 | span : List (Property msg) -> List (Node msg) -> Node msg 39 | span = 40 | node "span" 41 | 42 | 43 | a : List (Property msg) -> List (Node msg) -> Node msg 44 | a = 45 | node "a" 46 | 47 | 48 | h1 : List (Property msg) -> List (Node msg) -> Node msg 49 | h1 = 50 | node "h1" 51 | 52 | 53 | map : (a -> msg) -> Node a -> Node msg 54 | map = 55 | Native.VirtualDom.map 56 | 57 | 58 | type Property msg = Property 59 | 60 | 61 | property : String -> Decode.Value -> Property msg 62 | property = 63 | Native.VirtualDom.property 64 | 65 | 66 | attribute : String -> String -> Property msg 67 | attribute = 68 | Native.VirtualDom.attribute 69 | 70 | 71 | class : String -> Property msg 72 | class name = 73 | property "className" (Encode.string name) 74 | 75 | 76 | href : String -> Property msg 77 | href name = 78 | property "href" (Encode.string name) 79 | 80 | 81 | id : String -> Property msg 82 | id = 83 | attribute "id" 84 | 85 | 86 | style : List (String, String) -> Property msg 87 | style = 88 | Native.VirtualDom.style 89 | 90 | 91 | on : String -> Decode.Decoder msg -> Property msg 92 | on eventName decoder = 93 | onWithOptions eventName defaultOptions decoder 94 | 95 | 96 | onClick : msg -> Property msg 97 | onClick msg = 98 | on "click" (Decode.succeed msg) 99 | 100 | 101 | onWithOptions : String -> Options -> Decode.Decoder msg -> Property msg 102 | onWithOptions = 103 | Native.VirtualDom.on 104 | 105 | 106 | type alias Options = 107 | { stopPropagation : Bool 108 | , preventDefault : Bool 109 | } 110 | 111 | 112 | defaultOptions : Options 113 | defaultOptions = 114 | { stopPropagation = False 115 | , preventDefault = False 116 | } 117 | 118 | 119 | lazy : (a -> Node msg) -> a -> Node msg 120 | lazy = 121 | Native.VirtualDom.lazy 122 | 123 | 124 | lazy2 : (a -> b -> Node msg) -> a -> b -> Node msg 125 | lazy2 = 126 | Native.VirtualDom.lazy2 127 | 128 | 129 | lazy3 : (a -> b -> c -> Node msg) -> a -> b -> c -> Node msg 130 | lazy3 = 131 | Native.VirtualDom.lazy3 132 | 133 | 134 | keyedNode : String -> List (Property msg) -> List ( String, Node msg ) -> Node msg 135 | keyedNode = 136 | Native.VirtualDom.keyedNode 137 | 138 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Native/Regex.js: -------------------------------------------------------------------------------- 1 | //import Maybe, Native.List // 2 | 3 | var _elm_lang$core$Native_Regex = function() { 4 | 5 | function escape(str) 6 | { 7 | return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 8 | } 9 | function caseInsensitive(re) 10 | { 11 | return new RegExp(re.source, 'gi'); 12 | } 13 | function regex(raw) 14 | { 15 | return new RegExp(raw, 'g'); 16 | } 17 | 18 | function contains(re, string) 19 | { 20 | return string.match(re) !== null; 21 | } 22 | 23 | function find(n, re, str) 24 | { 25 | n = n.ctor === 'All' ? Infinity : n._0; 26 | var out = []; 27 | var number = 0; 28 | var string = str; 29 | var lastIndex = re.lastIndex; 30 | var prevLastIndex = -1; 31 | var result; 32 | while (number++ < n && (result = re.exec(string))) 33 | { 34 | if (prevLastIndex === re.lastIndex) break; 35 | var i = result.length - 1; 36 | var subs = new Array(i); 37 | while (i > 0) 38 | { 39 | var submatch = result[i]; 40 | subs[--i] = submatch === undefined 41 | ? _elm_lang$core$Maybe$Nothing 42 | : _elm_lang$core$Maybe$Just(submatch); 43 | } 44 | out.push({ 45 | match: result[0], 46 | submatches: _elm_lang$core$Native_List.fromArray(subs), 47 | index: result.index, 48 | number: number 49 | }); 50 | prevLastIndex = re.lastIndex; 51 | } 52 | re.lastIndex = lastIndex; 53 | return _elm_lang$core$Native_List.fromArray(out); 54 | } 55 | 56 | function replace(n, re, replacer, string) 57 | { 58 | n = n.ctor === 'All' ? Infinity : n._0; 59 | var count = 0; 60 | function jsReplacer(match) 61 | { 62 | if (count++ >= n) 63 | { 64 | return match; 65 | } 66 | var i = arguments.length - 3; 67 | var submatches = new Array(i); 68 | while (i > 0) 69 | { 70 | var submatch = arguments[i]; 71 | submatches[--i] = submatch === undefined 72 | ? _elm_lang$core$Maybe$Nothing 73 | : _elm_lang$core$Maybe$Just(submatch); 74 | } 75 | return replacer({ 76 | match: match, 77 | submatches: _elm_lang$core$Native_List.fromArray(submatches), 78 | index: arguments[arguments.length - 2], 79 | number: count 80 | }); 81 | } 82 | return string.replace(re, jsReplacer); 83 | } 84 | 85 | function split(n, re, str) 86 | { 87 | n = n.ctor === 'All' ? Infinity : n._0; 88 | if (n === Infinity) 89 | { 90 | return _elm_lang$core$Native_List.fromArray(str.split(re)); 91 | } 92 | var string = str; 93 | var result; 94 | var out = []; 95 | var start = re.lastIndex; 96 | var restoreLastIndex = re.lastIndex; 97 | while (n--) 98 | { 99 | if (!(result = re.exec(string))) break; 100 | out.push(string.slice(start, result.index)); 101 | start = re.lastIndex; 102 | } 103 | out.push(string.slice(start)); 104 | re.lastIndex = restoreLastIndex; 105 | return _elm_lang$core$Native_List.fromArray(out); 106 | } 107 | 108 | return { 109 | regex: regex, 110 | caseInsensitive: caseInsensitive, 111 | escape: escape, 112 | 113 | contains: F2(contains), 114 | find: F3(find), 115 | replace: F4(replace), 116 | split: F3(split) 117 | }; 118 | 119 | }(); 120 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Bitwise.elm: -------------------------------------------------------------------------------- 1 | module Test.Bitwise exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Bitwise 5 | import Test exposing (..) 6 | import Expect 7 | 8 | 9 | tests : Test 10 | tests = 11 | describe "Bitwise" 12 | [ describe "and" 13 | [ test "and with 32 bit integers" <| \() -> Expect.equal 1 (Bitwise.and 5 3) 14 | , test "and with 0 as first argument" <| \() -> Expect.equal 0 (Bitwise.and 0 1450) 15 | , test "and with 0 as second argument" <| \() -> Expect.equal 0 (Bitwise.and 274 0) 16 | , test "and with -1 as first argument" <| \() -> Expect.equal 2671 (Bitwise.and -1 2671) 17 | , test "and with -1 as second argument" <| \() -> Expect.equal 96 (Bitwise.and 96 -1) 18 | ] 19 | , describe "or" 20 | [ test "or with 32 bit integers" <| \() -> Expect.equal 15 (Bitwise.or 9 14) 21 | , test "or with 0 as first argument" <| \() -> Expect.equal 843 (Bitwise.or 0 843) 22 | , test "or with 0 as second argument" <| \() -> Expect.equal 19 (Bitwise.or 19 0) 23 | , test "or with -1 as first argument" <| \() -> Expect.equal -1 (Bitwise.or -1 2360) 24 | , test "or with -1 as second argument" <| \() -> Expect.equal -1 (Bitwise.or 3 -1) 25 | ] 26 | , describe "xor" 27 | [ test "xor with 32 bit integers" <| \() -> Expect.equal 604 (Bitwise.xor 580 24) 28 | , test "xor with 0 as first argument" <| \() -> Expect.equal 56 (Bitwise.xor 0 56) 29 | , test "xor with 0 as second argument" <| \() -> Expect.equal -268 (Bitwise.xor -268 0) 30 | , test "xor with -1 as first argument" <| \() -> Expect.equal -25 (Bitwise.xor -1 24) 31 | , test "xor with -1 as second argument" <| \() -> Expect.equal 25601 (Bitwise.xor -25602 -1) 32 | ] 33 | , describe "complement" 34 | [ test "complement a positive" <| \() -> Expect.equal -9 (Bitwise.complement 8) 35 | , test "complement a negative" <| \() -> Expect.equal 278 (Bitwise.complement -279) 36 | ] 37 | , describe "shiftLeftBy" 38 | [ test "8 |> shiftLeftBy 1 == 16" <| \() -> Expect.equal 16 (8 |> Bitwise.shiftLeftBy 1) 39 | , test "8 |> shiftLeftby 2 == 32" <| \() -> Expect.equal 32 (8 |> Bitwise.shiftLeftBy 2) 40 | ] 41 | , describe "shiftRightBy" 42 | [ test "32 |> shiftRight 1 == 16" <| \() -> Expect.equal 16 (32 |> Bitwise.shiftRightBy 1) 43 | , test "32 |> shiftRight 2 == 8" <| \() -> Expect.equal 8 (32 |> Bitwise.shiftRightBy 2) 44 | , test "-32 |> shiftRight 1 == -16" <| \() -> Expect.equal -16 (-32 |> Bitwise.shiftRightBy 1) 45 | ] 46 | , describe "shiftRightZfBy" 47 | [ test "32 |> shiftRightZfBy 1 == 16" <| \() -> Expect.equal 16 (32 |> Bitwise.shiftRightZfBy 1) 48 | , test "32 |> shiftRightZfBy 2 == 8" <| \() -> Expect.equal 8 (32 |> Bitwise.shiftRightZfBy 2) 49 | , test "-32 |> shiftRightZfBy 1 == 2147483632" <| \() -> Expect.equal 2147483632 (-32 |> Bitwise.shiftRightZfBy 1) 50 | ] 51 | ] 52 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Json.elm: -------------------------------------------------------------------------------- 1 | module Test.Json exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Result exposing (..) 5 | import Json.Decode as Json 6 | import String 7 | import Test exposing (..) 8 | import Expect 9 | 10 | 11 | tests : Test 12 | tests = 13 | describe "Json decode" 14 | [ intTests 15 | , customTests 16 | ] 17 | 18 | 19 | intTests : Test 20 | intTests = 21 | let 22 | testInt val str = 23 | case Json.decodeString Json.int str of 24 | Ok _ -> 25 | Expect.equal val True 26 | 27 | Err _ -> 28 | Expect.equal val False 29 | in 30 | describe "Json decode int" 31 | [ test "whole int" <| \() -> testInt True "4" 32 | , test "-whole int" <| \() -> testInt True "-4" 33 | , test "whole float" <| \() -> testInt True "4.0" 34 | , test "-whole float" <| \() -> testInt True "-4.0" 35 | , test "large int" <| \() -> testInt True "1801439850948" 36 | , test "-large int" <| \() -> testInt True "-1801439850948" 37 | , test "float" <| \() -> testInt False "4.2" 38 | , test "-float" <| \() -> testInt False "-4.2" 39 | , test "Infinity" <| \() -> testInt False "Infinity" 40 | , test "-Infinity" <| \() -> testInt False "-Infinity" 41 | , test "NaN" <| \() -> testInt False "NaN" 42 | , test "-NaN" <| \() -> testInt False "-NaN" 43 | , test "true" <| \() -> testInt False "true" 44 | , test "false" <| \() -> testInt False "false" 45 | , test "string" <| \() -> testInt False "\"string\"" 46 | , test "object" <| \() -> testInt False "{}" 47 | , test "null" <| \() -> testInt False "null" 48 | , test "undefined" <| \() -> testInt False "undefined" 49 | , test "Decoder expects object finds array, was crashing runtime." <| 50 | \() -> 51 | Expect.equal 52 | (Err "Expecting an object but instead got: []") 53 | (Json.decodeString (Json.dict Json.float) "[]") 54 | ] 55 | 56 | 57 | customTests : Test 58 | customTests = 59 | let 60 | jsonString = 61 | """{ "foo": "bar" }""" 62 | 63 | customErrorMessage = 64 | "I want to see this message!" 65 | 66 | myDecoder = 67 | Json.field "foo" Json.string |> Json.andThen (\_ -> Json.fail customErrorMessage) 68 | 69 | assertion = 70 | case Json.decodeString myDecoder jsonString of 71 | Ok _ -> 72 | Expect.fail "expected `customDecoder` to produce a value of type Err, but got Ok" 73 | 74 | Err message -> 75 | if String.contains customErrorMessage message then 76 | Expect.pass 77 | else 78 | Expect.fail <| 79 | "expected `customDecoder` to preserve user's error message '" 80 | ++ customErrorMessage 81 | ++ "', but instead got: " 82 | ++ message 83 | in 84 | test "customDecoder preserves user error messages" <| \() -> assertion 85 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/README.md: -------------------------------------------------------------------------------- 1 | # elm-decode-pipeline 2 | 3 | A library for building decoders using the pipeline [`(|>)`](http://package.elm-lang.org/packages/elm-lang/core/3.0.0/Basics#|>) 4 | operator and plain function calls. 5 | 6 | ## Motivation 7 | 8 | It's common to decode into a record that has a `type alias`. Here's an example 9 | of this from the [`object3`](http://package.elm-lang.org/packages/elm-lang/core/3.0.0/Json-Decode#object3) 10 | docs: 11 | 12 | ```elm 13 | type alias Job = { name : String, id : Int, completed : Bool } 14 | 15 | point : Decoder Job 16 | point = 17 | object3 Job 18 | ("name" := string) 19 | ("id" := int) 20 | ("completed" := bool) 21 | ``` 22 | 23 | This works because a record type alias can be called as a normal function. In 24 | that case it accepts one argument for each field (in whatever order the fields 25 | are declared in the type alias) and then returns an appropriate record built 26 | with those arguments. 27 | 28 | The `objectN` decoders are straightforward, but require manually changing N 29 | whenever the field count changes. This library provides functions designed to 30 | be used with the `|>` operator, with the goal of having decoders that are both 31 | easy to read and easy to modify. 32 | 33 | ## Examples 34 | 35 | Here is a decoder built with this library. 36 | 37 | ```elm 38 | import Json.Decode exposing (int, string, float, Decoder) 39 | import Json.Decode.Pipeline exposing (decode, required, optional, hardcoded) 40 | 41 | 42 | type alias User = 43 | { id : Int 44 | , email : Maybe String 45 | , name : String 46 | , percentExcited : Float 47 | } 48 | 49 | 50 | userDecoder : Decoder User 51 | userDecoder = 52 | decode User 53 | |> required "id" int 54 | |> required "email" (nullable string) -- `null` decodes to `Nothing` 55 | |> optional "name" string "(fallback if name is `null` or not present)" 56 | |> hardcoded 1.0 57 | ``` 58 | 59 | In this example: 60 | 61 | * `decode` is a synonym for [`succeed`](http://package.elm-lang.org/packages/elm-lang/core/3.0.0/Json-Decode#succeed) (it just reads better here) 62 | * `required "id" int` is similar to `("id" := int)` 63 | * `optional` is like `required`, but if the field is either `null` or not present, decoding does not fail; instead it succeeds with the provided fallback value. 64 | * `hardcoded` does not look at the provided JSON, and instead always decodes to the same value. 65 | 66 | You could use this decoder as follows: 67 | 68 | ```elm 69 | Json.Decode.decodeString 70 | userDecoder 71 | """ 72 | {"id": 123, "email": "sam@example.com", "name": "Sam Sample"} 73 | """ 74 | ``` 75 | 76 | The result would be: 77 | 78 | ```elm 79 | { id = 123 80 | , email = "sam@example.com" 81 | , name = "Sam Sample" 82 | , percentExcited = 1.0 83 | } 84 | ``` 85 | 86 | Alternatively, you could use it like so: 87 | 88 | ```elm 89 | Json.Decode.decodeString 90 | userDecoder 91 | """ 92 | {"id": 123, "email": "sam@example.com", "percentExcited": "(hardcoded)"} 93 | """ 94 | ``` 95 | 96 | In this case, the result would be: 97 | 98 | ```elm 99 | { id = 123 100 | , email = "sam@example.com" 101 | , name = "(fallback if name not present)" 102 | , percentExcited = 1.0 103 | } 104 | ``` 105 | 106 | --- 107 | [![NoRedInk](https://cloud.githubusercontent.com/assets/1094080/9069346/99522418-3a9d-11e5-8175-1c2bfd7a2ffe.png)][team] 108 | [team]: http://noredink.com/about/team 109 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Date.elm: -------------------------------------------------------------------------------- 1 | module Date exposing 2 | ( Date, fromString, toTime, fromTime 3 | , year, month, Month(..) 4 | , day, dayOfWeek, Day(..) 5 | , hour, minute, second, millisecond 6 | , now 7 | ) 8 | 9 | {-| Library for working with dates. Email the mailing list if you encounter 10 | issues with internationalization or locale formatting. 11 | 12 | # Dates 13 | @docs Date, now 14 | 15 | # Conversions 16 | @docs fromString, toTime, fromTime 17 | 18 | # Extractions 19 | @docs year, month, Month, day, dayOfWeek, Day, hour, minute, second, millisecond 20 | 21 | -} 22 | 23 | import Native.Date 24 | import Task exposing (Task) 25 | import Time exposing (Time) 26 | import Result exposing (Result) 27 | 28 | 29 | 30 | -- DATES 31 | 32 | 33 | {-| Representation of a date. 34 | -} 35 | type Date = Date 36 | 37 | 38 | {-| Get the `Date` at the moment when this task is run. 39 | -} 40 | now : Task x Date 41 | now = 42 | Task.map fromTime Time.now 43 | 44 | 45 | 46 | -- CONVERSIONS AND EXTRACTIONS 47 | 48 | 49 | {-| Represents the days of the week. 50 | -} 51 | type Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun 52 | 53 | 54 | {-| Represents the month of the year. 55 | -} 56 | type Month 57 | = Jan | Feb | Mar | Apr 58 | | May | Jun | Jul | Aug 59 | | Sep | Oct | Nov | Dec 60 | 61 | 62 | {-| Attempt to read a date from a string. 63 | -} 64 | fromString : String -> Result String Date 65 | fromString = 66 | Native.Date.fromString 67 | 68 | 69 | {-| Convert a `Date` to a time in milliseconds. 70 | 71 | A time is the number of milliseconds since 72 | [the Unix epoch](http://en.wikipedia.org/wiki/Unix_time). 73 | -} 74 | toTime : Date -> Time 75 | toTime = 76 | Native.Date.toTime 77 | 78 | 79 | {-| Convert a time in milliseconds into a `Date`. 80 | 81 | A time is the number of milliseconds since 82 | [the Unix epoch](http://en.wikipedia.org/wiki/Unix_time). 83 | -} 84 | fromTime : Time -> Date 85 | fromTime = 86 | Native.Date.fromTime 87 | 88 | 89 | {-| Extract the year of a given date. Given the date 23 June 1990 at 11:45AM 90 | this returns the integer `1990`. 91 | -} 92 | year : Date -> Int 93 | year = 94 | Native.Date.year 95 | 96 | 97 | {-| Extract the month of a given date. Given the date 23 June 1990 at 11:45AM 98 | this returns the month `Jun` as defined below. 99 | -} 100 | month : Date -> Month 101 | month = 102 | Native.Date.month 103 | 104 | 105 | {-| Extract the day of a given date. Given the date 23 June 1990 at 11:45AM 106 | this returns the integer `23`. 107 | -} 108 | day : Date -> Int 109 | day = 110 | Native.Date.day 111 | 112 | 113 | {-| Extract the day of the week for a given date. Given the date 23 June 114 | 1990 at 11:45AM this returns the day `Sat` as defined below. 115 | -} 116 | dayOfWeek : Date -> Day 117 | dayOfWeek = 118 | Native.Date.dayOfWeek 119 | 120 | 121 | {-| Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM 122 | this returns the integer `11`. 123 | -} 124 | hour : Date -> Int 125 | hour = 126 | Native.Date.hour 127 | 128 | 129 | {-| Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM 130 | this returns the integer `45`. 131 | -} 132 | minute : Date -> Int 133 | minute = 134 | Native.Date.minute 135 | 136 | 137 | {-| Extract the second of a given date. Given the date 23 June 1990 at 11:45AM 138 | this returns the integer `0`. 139 | -} 140 | second : Date -> Int 141 | second = 142 | Native.Date.second 143 | 144 | 145 | {-| Extract the millisecond of a given date. Given the date 23 June 1990 at 11:45:30.123AM 146 | this returns the integer `123`. 147 | -} 148 | millisecond : Date -> Int 149 | millisecond = 150 | Native.Date.millisecond 151 | -------------------------------------------------------------------------------- /src/Mobile.elm: -------------------------------------------------------------------------------- 1 | port module Main exposing (..) 2 | 3 | import NativeUi 4 | import NativeUi as Ui exposing (Node, Property) 5 | import NativeUi.Elements as Elements exposing (..) 6 | import NativeUi.Style as Style exposing (defaultTransform) 7 | import NativeUi.Events exposing (..) 8 | 9 | import Types exposing (..) 10 | import Model exposing (..) 11 | import Update exposing (..) 12 | import Message exposing (Msg(..)) 13 | import Subscription exposing (..) 14 | 15 | -- VIEW 16 | view : Model -> Node Msg 17 | view model = 18 | Elements.view 19 | [ Ui.style 20 | [ Style.paddingTop 32 21 | , Style.paddingLeft 16 22 | ] 23 | ] 24 | [ 25 | text [ Ui.style 26 | [ Style.fontSize 30] 27 | ] [ Ui.string "即時果菜市價查詢" ], 28 | Elements.view 29 | [ Ui.style 30 | [ Style.flex 1 31 | , Style.flexDirection "row" 32 | , Style.marginTop 12 33 | ] 34 | ] 35 | [ 36 | textInput 37 | [ 38 | Ui.style 39 | [ Style.width 300 40 | , Style.height 30 41 | , Style.backgroundColor "#444444" 42 | , Style.color "white" 43 | , Style.padding 5 44 | ] 45 | , onChangeText ChangeSearchInput 46 | ] [], 47 | button ClickSearch "grey" "搜索" 48 | ], 49 | Elements.view 50 | [ Ui.style 51 | [ Style.width 300 52 | , Style.height 500 53 | , Style.marginTop 42 54 | ] 55 | , onChangeText ChangeSearchInput 56 | ] 57 | [ 58 | case model.searched of 59 | True -> text [] [ Ui.string "搜索中 ..." ] 60 | False -> Elements.view [] [table model.data ] 61 | ] 62 | ] 63 | 64 | table : PriceData -> Node Msg 65 | table data = 66 | Elements.view 67 | [ Ui.style [] ] 68 | ( List.concat [ 69 | [ header () ], 70 | ( List.take 30 ( List.map (\x -> row x) data ) ) 71 | ] ) 72 | 73 | header : () -> Node Msg 74 | header () = 75 | let 76 | rowStyle = [ Ui.style [ Style.flex 1 , Style.flexDirection "row"]] 77 | colStyle = [ Ui.style [ Style.width 90, Style.height 30 ] ] 78 | in 79 | Elements.view rowStyle 80 | [ Elements.view colStyle [text [] [ Ui.string "時間" ]] 81 | , Elements.view colStyle [text [] [ Ui.string "名稱" ]] 82 | , Elements.view colStyle [text [] [ Ui.string "市場" ]] 83 | , Elements.view colStyle [text [] [ Ui.string "均價(台斤)" ]] 84 | ] 85 | 86 | row : Info -> Node Msg 87 | row info = 88 | let 89 | rowStyle = [ Ui.style [ Style.flex 1 , Style.flexDirection "row", Style.marginTop 16]] 90 | colStyle = [ Ui.style [ Style.width 90, Style.height 30 ] ] 91 | in 92 | Elements.view rowStyle 93 | [ Elements.view colStyle [text [] [ Ui.string info.tradeDate ]] 94 | , Elements.view colStyle [text [] [ Ui.string info.cropName ]] 95 | , Elements.view colStyle [text [] [ Ui.string info.marketName ]] 96 | , Elements.view colStyle [text [] [ Ui.string (toString (round (info.avgPrice * 0.6)))]] 97 | ] 98 | 99 | button : Msg -> String -> String -> Node Msg 100 | button msg color content = 101 | text 102 | [ Ui.style 103 | [ Style.color "white" 104 | , Style.textAlign "center" 105 | , Style.backgroundColor color 106 | , Style.width 60 107 | , Style.height 30 108 | , Style.fontSize 20 109 | , Style.paddingTop 5 110 | , Style.fontWeight "bold" 111 | ] 112 | , onPress msg 113 | ] 114 | [ Ui.string content ] 115 | 116 | main : Program Never Model Msg 117 | main = 118 | NativeUi.program 119 | { init = init 120 | , view = view 121 | , update = update 122 | , subscriptions = subscriptions 123 | } -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Process.elm: -------------------------------------------------------------------------------- 1 | module Process exposing 2 | ( Id 3 | , spawn 4 | , sleep 5 | , kill 6 | ) 7 | 8 | {-| 9 | 10 | # Processes 11 | @docs Id, spawn, sleep, kill 12 | 13 | ## Future Plans 14 | 15 | Right now, this library is pretty sparse. For example, there is no public API 16 | for processes to communicate with each other. This is a really important 17 | ability, but it is also something that is extraordinarily easy to get wrong! 18 | 19 | I think the trend will be towards an Erlang style of concurrency, where every 20 | process has an “event queue” that anyone can send messages to. I currently 21 | think the API will be extended to be more like this: 22 | 23 | type Id exit msg 24 | 25 | spawn : Task exit a -> Task x (Id exit Never) 26 | 27 | kill : Id exit msg -> Task x () 28 | 29 | send : Id exit msg -> msg -> Task x () 30 | 31 | A process `Id` will have two type variables to make sure all communication is 32 | valid. The `exit` type describes the messages that are produced if the process 33 | fails because of user code. So if processes are linked and trapping errors, 34 | they will need to handle this. The `msg` type just describes what kind of 35 | messages this process can be sent by strangers. 36 | 37 | We shall see though! This is just a draft that does not cover nearly everything 38 | it needs to, so the long-term vision for concurrency in Elm will be rolling out 39 | slowly as I get more data and experience. 40 | 41 | I ask that people bullish on compiling to node.js keep this in mind. I think we 42 | can do better than the hopelessly bad concurrency model of node.js, and I hope 43 | the Elm community will be supportive of being more ambitious, even if it takes 44 | longer. That’s kind of what Elm is all about. 45 | -} 46 | 47 | import Basics exposing (Never) 48 | import Native.Scheduler 49 | import Platform 50 | import Task exposing (Task) 51 | import Time exposing (Time) 52 | 53 | 54 | {-| A light-weight process that runs concurrently. You can use `spawn` to 55 | get a bunch of different tasks running in different processes. The Elm runtime 56 | will interleave their progress. So if a task is taking too long, we will pause 57 | it at an `andThen` and switch over to other stuff. 58 | 59 | **Note:** We make a distinction between *concurrency* which means interleaving 60 | different sequences and *parallelism* which means running different 61 | sequences at the exact same time. For example, a 62 | [time-sharing system](https://en.wikipedia.org/wiki/Time-sharing) is definitely 63 | concurrent, but not necessarily parallel. So even though JS runs within a 64 | single OS-level thread, Elm can still run things concurrently. 65 | -} 66 | type alias Id = 67 | Platform.ProcessId 68 | 69 | 70 | {-| Run a task in its own light-weight process. In the following example, 71 | `task1` and `task2` will be interleaved. If `task1` makes a long HTTP request 72 | or is just taking a long time, we can hop over to `task2` and do some work 73 | there. 74 | 75 | spawn task1 76 | |> Task.andThen (\_ -> spawn task2) 77 | 78 | **Note:** This creates a relatively restricted kind of `Process` because it 79 | cannot receive any messages. More flexibility for user-defined processes will 80 | come in a later release! 81 | -} 82 | spawn : Task x a -> Task y Id 83 | spawn = 84 | Native.Scheduler.spawn 85 | 86 | 87 | {-| Block progress on the current process for a given amount of time. The 88 | JavaScript equivalent of this is [`setTimeout`][setTimeout] which lets you 89 | delay work until later. 90 | 91 | [setTimeout]: https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout 92 | -} 93 | sleep : Time -> Task x () 94 | sleep = 95 | Native.Scheduler.sleep 96 | 97 | 98 | {-| Sometimes you `spawn` a process, but later decide it would be a waste to 99 | have it keep running and doing stuff. The `kill` function will force a process 100 | to bail on whatever task it is running. So if there is an HTTP request in 101 | flight, it will also abort the request. 102 | -} 103 | kill : Id -> Task x () 104 | kill = 105 | Native.Scheduler.kill 106 | 107 | -------------------------------------------------------------------------------- /elm-stuff/packages/NoRedInk/elm-decode-pipeline/3.0.0/tests/Tests.elm: -------------------------------------------------------------------------------- 1 | module Tests exposing (..) 2 | 3 | import Test exposing (..) 4 | import Expect exposing (Expectation) 5 | import Json.Decode.Pipeline 6 | exposing 7 | ( decode 8 | , required 9 | , requiredAt 10 | , optional 11 | , optionalAt 12 | , resolveResult 13 | ) 14 | import Json.Decode exposing (Decoder, string, null) 15 | 16 | 17 | {-| Run some JSON through a Decoder and return the result. 18 | -} 19 | runWith : String -> Decoder a -> Result String a 20 | runWith = 21 | flip Json.Decode.decodeString 22 | 23 | 24 | isError : Result err ok -> Bool 25 | isError result = 26 | case result of 27 | Err _ -> 28 | True 29 | 30 | Ok _ -> 31 | False 32 | 33 | 34 | expectErr : Result err ok -> Expectation 35 | expectErr result = 36 | isError result 37 | |> Expect.true ("Expected an Err but got " ++ toString result) 38 | 39 | 40 | all : Test 41 | all = 42 | describe 43 | "Json.Decode.Pipeline" 44 | [ test "should decode basic example" <| 45 | \() -> 46 | decode (,) 47 | |> required "a" string 48 | |> required "b" string 49 | |> runWith """{"a":"foo","b":"bar"}""" 50 | |> Expect.equal (Ok ( "foo", "bar" )) 51 | , test "should decode requiredAt fields" <| 52 | \() -> 53 | decode (,) 54 | |> requiredAt [ "a" ] string 55 | |> requiredAt [ "b", "c" ] string 56 | |> runWith """{"a":"foo","b":{"c":"bar"}}""" 57 | |> Expect.equal (Ok ( "foo", "bar" )) 58 | , test "should decode optionalAt fields" <| 59 | \() -> 60 | decode (,) 61 | |> optionalAt [ "a", "b" ] string "--" 62 | |> optionalAt [ "x", "y" ] string "--" 63 | |> runWith """{"a":{},"x":{"y":"bar"}}""" 64 | |> Expect.equal (Ok ( "--", "bar" )) 65 | , test "optional succeeds if the field is not present" <| 66 | \() -> 67 | decode (,) 68 | |> optional "a" string "--" 69 | |> optional "x" string "--" 70 | |> runWith """{"x":"five"}""" 71 | |> Expect.equal (Ok ( "--", "five" )) 72 | , test "optional succeeds with fallback if the field is present but null" <| 73 | \() -> 74 | decode (,) 75 | |> optional "a" string "--" 76 | |> optional "x" string "--" 77 | |> runWith """{"a":null,"x":"five"}""" 78 | |> Expect.equal (Ok ( "--", "five" )) 79 | , test "optional succeeds with result of the given decoder if the field is null and the decoder decodes nulls" <| 80 | \() -> 81 | decode (,) 82 | |> optional "a" (null "null") "--" 83 | |> optional "x" string "--" 84 | |> runWith """{"a":null,"x":"five"}""" 85 | |> Expect.equal (Ok ( "null", "five" )) 86 | , test "optional fails if the field is present but doesn't decode" <| 87 | \() -> 88 | decode (,) 89 | |> optional "a" string "--" 90 | |> optional "x" string "--" 91 | |> runWith """{"x":5}""" 92 | |> expectErr 93 | , test "optionalAt fails if the field is present but doesn't decode" <| 94 | \() -> 95 | decode (,) 96 | |> optionalAt [ "a", "b" ] string "--" 97 | |> optionalAt [ "x", "y" ] string "--" 98 | |> runWith """{"a":{},"x":{"y":5}}""" 99 | |> expectErr 100 | , test "resolveResult bubbles up decoded Err results" <| 101 | \() -> 102 | decode Err 103 | |> required "error" string 104 | |> resolveResult 105 | |> runWith """{"error":"invalid"}""" 106 | |> expectErr 107 | , test "resolveResult bubbles up decoded Ok results" <| 108 | \() -> 109 | decode Ok 110 | |> required "ok" string 111 | |> resolveResult 112 | |> runWith """{"ok":"valid"}""" 113 | |> Expect.equal (Ok "valid") 114 | ] 115 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Platform.elm: -------------------------------------------------------------------------------- 1 | module Platform exposing 2 | ( Program, program, programWithFlags 3 | , Task, ProcessId 4 | , Router, sendToApp, sendToSelf 5 | ) 6 | 7 | {-| 8 | 9 | # Programs 10 | @docs Program, program, programWithFlags 11 | 12 | # Platform Internals 13 | 14 | ## Tasks and Processes 15 | @docs Task, ProcessId 16 | 17 | ## Effect Manager Helpers 18 | 19 | An extremely tiny portion of library authors should ever write effect managers. 20 | Fundamentally, Elm needs maybe 10 of them total. I get that people are smart, 21 | curious, etc. but that is not a substitute for a legitimate reason to make an 22 | effect manager. Do you have an *organic need* this fills? Or are you just 23 | curious? Public discussions of your explorations should be framed accordingly. 24 | 25 | @docs Router, sendToApp, sendToSelf 26 | -} 27 | 28 | import Basics exposing (Never) 29 | import Native.Platform 30 | import Native.Scheduler 31 | import Platform.Cmd exposing (Cmd) 32 | import Platform.Sub exposing (Sub) 33 | 34 | 35 | 36 | -- PROGRAMS 37 | 38 | 39 | {-| A `Program` describes how to manage your Elm app. 40 | 41 | You can create [headless][] programs with the [`program`](#program) and 42 | [`programWithFlags`](#programWithFlags) functions. Similar functions exist in 43 | [`Html`][html] that let you specify a view. 44 | 45 | [headless]: https://en.wikipedia.org/wiki/Headless_software 46 | [html]: http://package.elm-lang.org/packages/elm-lang/html/latest/Html 47 | 48 | Honestly, it is totally normal if this seems crazy at first. The best way to 49 | understand is to work through [guide.elm-lang.org](http://guide.elm-lang.org/). 50 | It makes way more sense in context! 51 | -} 52 | type Program flags model msg = Program 53 | 54 | 55 | {-| Create a [headless][] program. This is great if you want to use Elm as the 56 | “brain” for something else. You can still communicate with JS via 57 | ports and manage your model, you just do not have to specify a `view`. 58 | 59 | [headless]: https://en.wikipedia.org/wiki/Headless_software 60 | 61 | Initializing a headless program from JavaScript looks like this: 62 | 63 | ```javascript 64 | var app = Elm.MyThing.worker(); 65 | ``` 66 | -} 67 | program 68 | : { init : (model, Cmd msg) 69 | , update : msg -> model -> (model, Cmd msg) 70 | , subscriptions : model -> Sub msg 71 | } 72 | -> Program Never model msg 73 | program = 74 | Native.Platform.program 75 | 76 | 77 | {-| Same as [`program`](#program), but you can provide flags. Initializing a 78 | headless program (with flags) from JavaScript looks like this: 79 | 80 | ```javascript 81 | var app = Elm.MyThing.worker({ user: 'Tom', token: 1234 }); 82 | ``` 83 | 84 | Whatever argument you provide to `worker` will get converted to an Elm value, 85 | allowing you to configure your Elm program however you want from JavaScript! 86 | -} 87 | programWithFlags 88 | : { init : flags -> (model, Cmd msg) 89 | , update : msg -> model -> (model, Cmd msg) 90 | , subscriptions : model -> Sub msg 91 | } 92 | -> Program flags model msg 93 | programWithFlags = 94 | Native.Platform.programWithFlags 95 | 96 | 97 | 98 | -- TASKS and PROCESSES 99 | 100 | {-| Head over to the documentation for the [`Task`](Task) module for more 101 | information on this. It is only defined here because it is a platform 102 | primitive. 103 | -} 104 | type Task err ok = Task 105 | 106 | 107 | {-| Head over to the documentation for the [`Process`](Process) module for 108 | information on this. It is only defined here because it is a platform 109 | primitive. 110 | -} 111 | type ProcessId = ProcessId 112 | 113 | 114 | 115 | -- EFFECT MANAGER INTERNALS 116 | 117 | 118 | {-| An effect manager has access to a “router” that routes messages between 119 | the main app and your individual effect manager. 120 | -} 121 | type Router appMsg selfMsg = 122 | Router 123 | 124 | 125 | {-| Send the router a message for the main loop of your app. This message will 126 | be handled by the overall `update` function, just like events from `Html`. 127 | -} 128 | sendToApp : Router msg a -> msg -> Task x () 129 | sendToApp = 130 | Native.Platform.sendToApp 131 | 132 | 133 | {-| Send the router a message for your effect manager. This message will 134 | be routed to the `onSelfMsg` function, where you can update the state of your 135 | effect manager as necessary. 136 | 137 | As an example, the effect manager for web sockets 138 | -} 139 | sendToSelf : Router a msg -> msg -> Task x () 140 | sendToSelf = 141 | Native.Platform.sendToSelf 142 | 143 | 144 | hack = 145 | Native.Scheduler.succeed 146 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/changelog.md: -------------------------------------------------------------------------------- 1 | # 0.15 2 | 3 | ### Syntax 4 | 5 | New `import` syntax with keyword `exposing`. 6 | 7 | ### Module Changes 8 | 9 | * Move `Http` to `elm-http` package and totally redo API 10 | * Remove `WebSocket` module 11 | * Add `Task` module 12 | 13 | ### Channels become Mailboxes 14 | 15 | `Graphics.Input` now works with this API (from module `Signal`): 16 | 17 | ```elm 18 | type alias Mailbox a = { address : Address a, signal : Signal a } 19 | 20 | mailbox : a -> Mailbox a 21 | ``` 22 | 23 | You can then send messages to the `Address` with functions like `Signal.send` 24 | and `Signal.message`, or create forwarding addresses with `Signal.forwardTo`. 25 | 26 | ### Text in Collages 27 | 28 | `Graphics.Collage` now has two new functions: 29 | 30 | ```elm 31 | text : Text -> Form 32 | outlinedText : LineStyle -> Text -> Form 33 | ``` 34 | 35 | These functions render text with the canvas, making things quite a bit faster. 36 | The underlying implementation of `Text` has also been improved dramatically. 37 | 38 | ### Miscellaneous 39 | 40 | * Change types of `head`, `tail`, `maximum`, `minimum` by wrapping output in `Maybe` 41 | * Move `leftAligned`, `centered`, `rightAligned` from `Text` to `Graphics.Element` 42 | * Move `asText` from `Text` to `Graphics.Element`, renaming it to `show` in the process 43 | * Remove `Text.plainText` (can be replaced by `Graphics.Element.leftAligned << Text.fromString`) 44 | * Change type of `Keyboard.keysDown` from `Signal (List KeyCode)` to `Signal (Set KeyCode)` 45 | * Remove `Keyboard.directions` 46 | * Rename `Keyboard.lastPressed` to `Keyboard.presses` 47 | 48 | 49 | # 0.14 50 | 51 | ### Syntax 52 | 53 | * Keyword `type` becomes `type alias` 54 | * Keyword `data` becomes `type` 55 | * Remove special list syntax in types, so `[a]` becomes `List a` 56 | 57 | 58 | ### Reduce Default Imports 59 | 60 | The set of default imports has been reduced to the following: 61 | 62 | ```haskell 63 | import Basics (..) 64 | import Maybe ( Maybe( Just, Nothing ) ) 65 | import Result ( Result( Ok, Err ) ) 66 | import List ( List ) 67 | import Signal ( Signal ) 68 | ``` 69 | 70 | ### Make JSON parsing easy 71 | 72 | * Added `Json.Decode` and `Json.Encode` libraries 73 | 74 | 75 | ### Use more natural names 76 | 77 | * Rename `String.show` to `String.toString` 78 | 79 | * Replace `List.zip` with `List.map2 (,)` 80 | * Replace `List.zipWith f` with `List.map2 f` 81 | 82 | * Rename `Signal.liftN` to `Signal.mapN` 83 | * Rename `Signal.merges` to `Signal.mergeMany` 84 | 85 | 86 | ### Simplify Signal Library 87 | 88 | * Revamp `Input` concept as `Signal.Channel` 89 | * Remove `Signal.count` 90 | * Remove `Signal.countIf` 91 | * Remove `Signal.combine` 92 | 93 | 94 | ### Randomness Done Right 95 | 96 | * No longer signal-based 97 | * Use a `Generator` to create random values 98 | 99 | 100 | 101 | ### Revamp Maybes and Error Handling 102 | 103 | * Add the following functions to `Maybe` 104 | 105 | withDefault : a -> Maybe a -> a 106 | oneOf : List (Maybe a) -> Maybe a 107 | map : (a -> b) -> Maybe a -> Maybe b 108 | andThen : Maybe a -> (a -> Maybe b) -> Maybe b 109 | 110 | * Remove `Maybe.maybe` so `maybe 0 sqrt Nothing` becomes `withDefault 0 (map sqrt Nothing)` 111 | 112 | * Remove `Maybe.isJust` and `Maybe.isNothing` in favor of pattern matching 113 | 114 | * Add `Result` library for proper error handling. This is for cases when 115 | you want a computation to succeed, but if there is a mistake, it should 116 | produce a nice error message. 117 | 118 | * Remove `Either` in favor of `Result` or custom union types 119 | 120 | * Revamp functions that result in a `Maybe`. 121 | 122 | - Remove `Dict.getOrElse` and `Dict.getOrFail` in favor of `withDefault 0 (Dict.get key dict)` 123 | - Remove `Array.getOrElse` and `Array.getOrFail` in favor of `withDefault 0 (Array.get index array)` 124 | - Change `String.toInt : String -> Maybe Int` to `String.toInt : String -> Result String Int` 125 | - Change `String.toFloat : String -> Maybe Float` to `String.toFloat : String -> Result String Float` 126 | 127 | 128 | ### Make appending more logical 129 | 130 | * Add the following functions to `Text`: 131 | 132 | empty : Text 133 | append : Text -> Text -> Text 134 | concat : [Text] -> Text 135 | join : Text -> [Text] -> Text 136 | 137 | * Make the following changes in `List`: 138 | - Replace `(++)` with `append` 139 | - Remove `join` 140 | 141 | ### Miscellaneous 142 | 143 | * Rename `Text.toText` to `Text.fromString` 144 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Maybe.elm: -------------------------------------------------------------------------------- 1 | module Maybe exposing 2 | ( Maybe(Just,Nothing) 3 | , andThen 4 | , map, map2, map3, map4, map5 5 | , withDefault 6 | ) 7 | 8 | {-| This library fills a bunch of important niches in Elm. A `Maybe` can help 9 | you with optional arguments, error handling, and records with optional fields. 10 | 11 | # Definition 12 | @docs Maybe 13 | 14 | # Common Helpers 15 | @docs withDefault, map, map2, map3, map4, map5 16 | 17 | # Chaining Maybes 18 | @docs andThen 19 | -} 20 | 21 | {-| Represent values that may or may not exist. It can be useful if you have a 22 | record field that is only filled in sometimes. Or if a function takes a value 23 | sometimes, but does not absolutely need it. 24 | 25 | -- A person, but maybe we do not know their age. 26 | type alias Person = 27 | { name : String 28 | , age : Maybe Int 29 | } 30 | 31 | tom = { name = "Tom", age = Just 42 } 32 | sue = { name = "Sue", age = Nothing } 33 | -} 34 | type Maybe a 35 | = Just a 36 | | Nothing 37 | 38 | 39 | {-| Provide a default value, turning an optional value into a normal 40 | value. This comes in handy when paired with functions like 41 | [`Dict.get`](Dict#get) which gives back a `Maybe`. 42 | 43 | withDefault 100 (Just 42) -- 42 44 | withDefault 100 Nothing -- 100 45 | 46 | withDefault "unknown" (Dict.get "Tom" Dict.empty) -- "unknown" 47 | 48 | -} 49 | withDefault : a -> Maybe a -> a 50 | withDefault default maybe = 51 | case maybe of 52 | Just value -> value 53 | Nothing -> default 54 | 55 | 56 | {-| Transform a `Maybe` value with a given function: 57 | 58 | map sqrt (Just 9) == Just 3 59 | map sqrt Nothing == Nothing 60 | -} 61 | map : (a -> b) -> Maybe a -> Maybe b 62 | map f maybe = 63 | case maybe of 64 | Just value -> Just (f value) 65 | Nothing -> Nothing 66 | 67 | 68 | {-| Apply a function if all the arguments are `Just` a value. 69 | 70 | map2 (+) (Just 3) (Just 4) == Just 7 71 | map2 (+) (Just 3) Nothing == Nothing 72 | map2 (+) Nothing (Just 4) == Nothing 73 | -} 74 | map2 : (a -> b -> value) -> Maybe a -> Maybe b -> Maybe value 75 | map2 func ma mb = 76 | case (ma,mb) of 77 | (Just a, Just b) -> 78 | Just (func a b) 79 | 80 | _ -> 81 | Nothing 82 | 83 | 84 | {-|-} 85 | map3 : (a -> b -> c -> value) -> Maybe a -> Maybe b -> Maybe c -> Maybe value 86 | map3 func ma mb mc = 87 | case (ma,mb,mc) of 88 | (Just a, Just b, Just c) -> 89 | Just (func a b c) 90 | 91 | _ -> 92 | Nothing 93 | 94 | 95 | {-|-} 96 | map4 : (a -> b -> c -> d -> value) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe value 97 | map4 func ma mb mc md = 98 | case (ma,mb,mc,md) of 99 | (Just a, Just b, Just c, Just d) -> 100 | Just (func a b c d) 101 | 102 | _ -> 103 | Nothing 104 | 105 | 106 | {-|-} 107 | map5 : (a -> b -> c -> d -> e -> value) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe value 108 | map5 func ma mb mc md me = 109 | case (ma,mb,mc,md,me) of 110 | (Just a, Just b, Just c, Just d, Just e) -> 111 | Just (func a b c d e) 112 | 113 | _ -> 114 | Nothing 115 | 116 | 117 | {-| Chain together many computations that may fail. It is helpful to see its 118 | definition: 119 | 120 | andThen : (a -> Maybe b) -> Maybe a -> Maybe b 121 | andThen callback maybe = 122 | case maybe of 123 | Just value -> 124 | callback value 125 | 126 | Nothing -> 127 | Nothing 128 | 129 | This means we only continue with the callback if things are going well. For 130 | example, say you need to use (`head : List Int -> Maybe Int`) to get the 131 | first month from a `List` and then make sure it is between 1 and 12: 132 | 133 | toValidMonth : Int -> Maybe Int 134 | toValidMonth month = 135 | if month >= 1 && month <= 12 then 136 | Just month 137 | else 138 | Nothing 139 | 140 | getFirstMonth : List Int -> Maybe Int 141 | getFirstMonth months = 142 | head months 143 | |> andThen toValidMonth 144 | 145 | If `head` fails and results in `Nothing` (because the `List` was `empty`), 146 | this entire chain of operations will short-circuit and result in `Nothing`. 147 | If `toValidMonth` results in `Nothing`, again the chain of computations 148 | will result in `Nothing`. 149 | -} 150 | andThen : (a -> Maybe b) -> Maybe a -> Maybe b 151 | andThen callback maybeValue = 152 | case maybeValue of 153 | Just value -> 154 | callback value 155 | 156 | Nothing -> 157 | Nothing 158 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/Char.elm: -------------------------------------------------------------------------------- 1 | module Test.Char exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import Char exposing (..) 5 | import List 6 | import Test exposing (..) 7 | import Expect 8 | 9 | 10 | lower = 11 | [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ] 12 | 13 | 14 | upper = 15 | [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ] 16 | 17 | 18 | dec = 19 | [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] 20 | 21 | 22 | oct = 23 | List.take 8 dec 24 | 25 | 26 | hexLower = 27 | List.take 6 lower 28 | 29 | 30 | hexUpper = 31 | List.take 6 upper 32 | 33 | 34 | hex = 35 | List.append hexLower hexUpper |> List.append dec 36 | 37 | 38 | lowerCodes = 39 | List.range 97 (97 + List.length lower - 1) 40 | 41 | 42 | upperCodes = 43 | List.range 65 (65 + List.length upper - 1) 44 | 45 | 46 | decCodes = 47 | List.range 48 (48 + List.length dec - 1) 48 | 49 | 50 | oneOf : List a -> a -> Bool 51 | oneOf = 52 | flip List.member 53 | 54 | 55 | tests : Test 56 | tests = 57 | describe "Char" 58 | [ describe "toCode" 59 | [ test "a-z" <| \() -> Expect.equal (lowerCodes) (List.map toCode lower) 60 | , test "A-Z" <| \() -> Expect.equal (upperCodes) (List.map toCode upper) 61 | , test "0-9" <| \() -> Expect.equal (decCodes) (List.map toCode dec) 62 | ] 63 | , describe "fromCode" 64 | [ test "a-z" <| \() -> Expect.equal (lower) (List.map fromCode lowerCodes) 65 | , test "A-Z" <| \() -> Expect.equal (upper) (List.map fromCode upperCodes) 66 | , test "0-9" <| \() -> Expect.equal (dec) (List.map fromCode decCodes) 67 | ] 68 | , describe "toLocaleLower" 69 | [ test "a-z" <| \() -> Expect.equal (lower) (List.map toLocaleLower lower) 70 | , test "A-Z" <| \() -> Expect.equal (lower) (List.map toLocaleLower upper) 71 | , test "0-9" <| \() -> Expect.equal (dec) (List.map toLocaleLower dec) 72 | ] 73 | , describe "toLocaleUpper" 74 | [ test "a-z" <| \() -> Expect.equal (upper) (List.map toLocaleUpper lower) 75 | , test "A-Z" <| \() -> Expect.equal (upper) (List.map toLocaleUpper upper) 76 | , test "0-9" <| \() -> Expect.equal (dec) (List.map toLocaleUpper dec) 77 | ] 78 | , describe "toLower" 79 | [ test "a-z" <| \() -> Expect.equal (lower) (List.map toLower lower) 80 | , test "A-Z" <| \() -> Expect.equal (lower) (List.map toLower upper) 81 | , test "0-9" <| \() -> Expect.equal (dec) (List.map toLower dec) 82 | ] 83 | , describe "toUpper" 84 | [ test "a-z" <| \() -> Expect.equal (upper) (List.map toUpper lower) 85 | , test "A-Z" <| \() -> Expect.equal (upper) (List.map toUpper upper) 86 | , test "0-9" <| \() -> Expect.equal (dec) (List.map toUpper dec) 87 | ] 88 | , describe "isLower" 89 | [ test "a-z" <| \() -> Expect.equal (True) (List.all isLower lower) 90 | , test "A-Z" <| \() -> Expect.equal (False) (List.any isLower upper) 91 | , test "0-9" <| \() -> Expect.equal (False) (List.any isLower dec) 92 | ] 93 | , describe "isUpper" 94 | [ test "a-z" <| \() -> Expect.equal (False) (List.any isUpper lower) 95 | , test "A-Z" <| \() -> Expect.equal (True) (List.all isUpper upper) 96 | , test "0-9" <| \() -> Expect.equal (False) (List.any isUpper dec) 97 | ] 98 | , describe "isDigit" 99 | [ test "a-z" <| \() -> Expect.equal (False) (List.any isDigit lower) 100 | , test "A-Z" <| \() -> Expect.equal (False) (List.any isDigit upper) 101 | , test "0-9" <| \() -> Expect.equal (True) (List.all isDigit dec) 102 | ] 103 | , describe "isHexDigit" 104 | [ test "a-z" <| \() -> Expect.equal (List.map (oneOf hex) lower) (List.map isHexDigit lower) 105 | , test "A-Z" <| \() -> Expect.equal (List.map (oneOf hex) upper) (List.map isHexDigit upper) 106 | , test "0-9" <| \() -> Expect.equal (True) (List.all isHexDigit dec) 107 | ] 108 | , describe "isOctDigit" 109 | [ test "a-z" <| \() -> Expect.equal (False) (List.any isOctDigit lower) 110 | , test "A-Z" <| \() -> Expect.equal (False) (List.any isOctDigit upper) 111 | , test "0-9" <| \() -> Expect.equal (List.map (oneOf oct) dec) (List.map isOctDigit dec) 112 | ] 113 | ] 114 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Set.elm: -------------------------------------------------------------------------------- 1 | module Set exposing 2 | ( Set 3 | , empty, singleton, insert, remove 4 | , isEmpty, member, size 5 | , foldl, foldr, map 6 | , filter, partition 7 | , union, intersect, diff 8 | , toList, fromList 9 | ) 10 | 11 | {-| A set of unique values. The values can be any comparable type. This 12 | includes `Int`, `Float`, `Time`, `Char`, `String`, and tuples or lists 13 | of comparable types. 14 | 15 | Insert, remove, and query operations all take *O(log n)* time. 16 | 17 | # Sets 18 | @docs Set 19 | 20 | # Build 21 | @docs empty, singleton, insert, remove 22 | 23 | # Query 24 | @docs isEmpty, member, size 25 | 26 | # Combine 27 | @docs union, intersect, diff 28 | 29 | # Lists 30 | @docs toList, fromList 31 | 32 | # Transform 33 | @docs map, foldl, foldr, filter, partition 34 | 35 | -} 36 | 37 | import Basics exposing ((<|)) 38 | import Dict as Dict 39 | import List as List 40 | 41 | 42 | {-| Represents a set of unique values. So `(Set Int)` is a set of integers and 43 | `(Set String)` is a set of strings. 44 | -} 45 | type Set t = 46 | Set_elm_builtin (Dict.Dict t ()) 47 | 48 | 49 | {-| Create an empty set. 50 | -} 51 | empty : Set a 52 | empty = 53 | Set_elm_builtin Dict.empty 54 | 55 | 56 | {-| Create a set with one value. 57 | -} 58 | singleton : comparable -> Set comparable 59 | singleton k = 60 | Set_elm_builtin <| Dict.singleton k () 61 | 62 | 63 | {-| Insert a value into a set. 64 | -} 65 | insert : comparable -> Set comparable -> Set comparable 66 | insert k (Set_elm_builtin d) = 67 | Set_elm_builtin <| Dict.insert k () d 68 | 69 | 70 | {-| Remove a value from a set. If the value is not found, no changes are made. 71 | -} 72 | remove : comparable -> Set comparable -> Set comparable 73 | remove k (Set_elm_builtin d) = 74 | Set_elm_builtin <| Dict.remove k d 75 | 76 | 77 | {-| Determine if a set is empty. 78 | -} 79 | isEmpty : Set a -> Bool 80 | isEmpty (Set_elm_builtin d) = 81 | Dict.isEmpty d 82 | 83 | 84 | {-| Determine if a value is in a set. 85 | -} 86 | member : comparable -> Set comparable -> Bool 87 | member k (Set_elm_builtin d) = 88 | Dict.member k d 89 | 90 | 91 | {-| Determine the number of elements in a set. 92 | -} 93 | size : Set a -> Int 94 | size (Set_elm_builtin d) = 95 | Dict.size d 96 | 97 | 98 | {-| Get the union of two sets. Keep all values. 99 | -} 100 | union : Set comparable -> Set comparable -> Set comparable 101 | union (Set_elm_builtin d1) (Set_elm_builtin d2) = 102 | Set_elm_builtin <| Dict.union d1 d2 103 | 104 | 105 | {-| Get the intersection of two sets. Keeps values that appear in both sets. 106 | -} 107 | intersect : Set comparable -> Set comparable -> Set comparable 108 | intersect (Set_elm_builtin d1) (Set_elm_builtin d2) = 109 | Set_elm_builtin <| Dict.intersect d1 d2 110 | 111 | 112 | {-| Get the difference between the first set and the second. Keeps values 113 | that do not appear in the second set. 114 | -} 115 | diff : Set comparable -> Set comparable -> Set comparable 116 | diff (Set_elm_builtin d1) (Set_elm_builtin d2) = 117 | Set_elm_builtin <| Dict.diff d1 d2 118 | 119 | 120 | {-| Convert a set into a list, sorted from lowest to highest. 121 | -} 122 | toList : Set comparable -> List comparable 123 | toList (Set_elm_builtin d) = 124 | Dict.keys d 125 | 126 | 127 | {-| Convert a list into a set, removing any duplicates. 128 | -} 129 | fromList : List comparable -> Set comparable 130 | fromList xs = List.foldl insert empty xs 131 | 132 | 133 | {-| Fold over the values in a set, in order from lowest to highest. 134 | -} 135 | foldl : (comparable -> b -> b) -> b -> Set comparable -> b 136 | foldl f b (Set_elm_builtin d) = 137 | Dict.foldl (\k _ b -> f k b) b d 138 | 139 | 140 | {-| Fold over the values in a set, in order from highest to lowest. 141 | -} 142 | foldr : (comparable -> b -> b) -> b -> Set comparable -> b 143 | foldr f b (Set_elm_builtin d) = 144 | Dict.foldr (\k _ b -> f k b) b d 145 | 146 | 147 | {-| Map a function onto a set, creating a new set with no duplicates. 148 | -} 149 | map : (comparable -> comparable2) -> Set comparable -> Set comparable2 150 | map f s = fromList (List.map f (toList s)) 151 | 152 | 153 | {-| Create a new set consisting only of elements which satisfy a predicate. 154 | -} 155 | filter : (comparable -> Bool) -> Set comparable -> Set comparable 156 | filter p (Set_elm_builtin d) = 157 | Set_elm_builtin <| Dict.filter (\k _ -> p k) d 158 | 159 | 160 | {-| Create two new sets; the first consisting of elements which satisfy a 161 | predicate, the second consisting of elements which do not. 162 | -} 163 | partition : (comparable -> Bool) -> Set comparable -> (Set comparable, Set comparable) 164 | partition p (Set_elm_builtin d) = 165 | let 166 | (p1, p2) = Dict.partition (\k _ -> p k) d 167 | in 168 | (Set_elm_builtin p1, Set_elm_builtin p2) 169 | -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/tests/Test/String.elm: -------------------------------------------------------------------------------- 1 | module Test.String exposing (tests) 2 | 3 | import Basics exposing (..) 4 | import List 5 | import Maybe exposing (..) 6 | import Result exposing (Result(..)) 7 | import String 8 | import Test exposing (..) 9 | import Expect 10 | 11 | 12 | tests : Test 13 | tests = 14 | let 15 | simpleTests = 16 | describe "Simple Stuff" 17 | [ test "is empty" <| \() -> Expect.equal True (String.isEmpty "") 18 | , test "is not empty" <| \() -> Expect.equal True (not (String.isEmpty ("the world"))) 19 | , test "length" <| \() -> Expect.equal 11 (String.length "innumerable") 20 | , test "endsWith" <| \() -> Expect.equal True <| String.endsWith "ship" "spaceship" 21 | , test "reverse" <| \() -> Expect.equal "desserts" (String.reverse "stressed") 22 | , test "repeat" <| \() -> Expect.equal "hahaha" (String.repeat 3 "ha") 23 | , test "indexes" <| \() -> Expect.equal [ 0, 2 ] (String.indexes "a" "aha") 24 | , test "empty indexes" <| \() -> Expect.equal [] (String.indexes "" "aha") 25 | ] 26 | 27 | combiningTests = 28 | describe "Combining Strings" 29 | [ test "uncons non-empty" <| \() -> Expect.equal (Just ( 'a', "bc" )) (String.uncons "abc") 30 | , test "uncons empty" <| \() -> Expect.equal Nothing (String.uncons "") 31 | , test "append 1" <| \() -> Expect.equal "butterfly" (String.append "butter" "fly") 32 | , test "append 2" <| \() -> Expect.equal "butter" (String.append "butter" "") 33 | , test "append 3" <| \() -> Expect.equal "butter" (String.append "" "butter") 34 | , test "concat" <| \() -> Expect.equal "nevertheless" (String.concat [ "never", "the", "less" ]) 35 | , test "split commas" <| \() -> Expect.equal [ "cat", "dog", "cow" ] (String.split "," "cat,dog,cow") 36 | , test "split slashes" <| \() -> Expect.equal [ "home", "steve", "Desktop", "" ] (String.split "/" "home/steve/Desktop/") 37 | , test "join spaces" <| \() -> Expect.equal "cat dog cow" (String.join " " [ "cat", "dog", "cow" ]) 38 | , test "join slashes" <| \() -> Expect.equal "home/steve/Desktop" (String.join "/" [ "home", "steve", "Desktop" ]) 39 | , test "slice 1" <| \() -> Expect.equal "c" (String.slice 2 3 "abcd") 40 | , test "slice 2" <| \() -> Expect.equal "abc" (String.slice 0 3 "abcd") 41 | , test "slice 3" <| \() -> Expect.equal "abc" (String.slice 0 -1 "abcd") 42 | , test "slice 4" <| \() -> Expect.equal "cd" (String.slice -2 4 "abcd") 43 | ] 44 | 45 | intTests = 46 | describe "String.toInt" 47 | [ goodInt "1234" 1234 48 | , goodInt "+1234" 1234 49 | , goodInt "-1234" -1234 50 | , badInt "1.34" 51 | , badInt "1e31" 52 | , badInt "123a" 53 | , goodInt "0123" 123 54 | , goodInt "0x001A" 26 55 | , goodInt "0x001a" 26 56 | , goodInt "0xBEEF" 48879 57 | , badInt "0x12.0" 58 | , badInt "0x12an" 59 | ] 60 | 61 | floatTests = 62 | describe "String.toFloat" 63 | [ goodFloat "123" 123 64 | , goodFloat "3.14" 3.14 65 | , goodFloat "+3.14" 3.14 66 | , goodFloat "-3.14" -3.14 67 | , goodFloat "0.12" 0.12 68 | , goodFloat ".12" 0.12 69 | , goodFloat "1e-42" 1e-42 70 | , goodFloat "6.022e23" 6.022e23 71 | , goodFloat "6.022E23" 6.022e23 72 | , goodFloat "6.022e+23" 6.022e23 73 | , badFloat "6.022e" 74 | , badFloat "6.022n" 75 | , badFloat "6.022.31" 76 | ] 77 | in 78 | describe "String" [ simpleTests, combiningTests, intTests, floatTests ] 79 | 80 | 81 | 82 | -- NUMBER HELPERS 83 | 84 | 85 | goodInt : String -> Int -> Test 86 | goodInt str int = 87 | test str <| \_ -> 88 | Expect.equal (Ok int) (String.toInt str) 89 | 90 | 91 | badInt : String -> Test 92 | badInt str = 93 | test str <| \_ -> 94 | Expect.equal 95 | (Err ("could not convert string '" ++ str ++ "' to an Int")) 96 | (String.toInt str) 97 | 98 | 99 | goodFloat : String -> Float -> Test 100 | goodFloat str float = 101 | test str <| \_ -> 102 | Expect.equal (Ok float) (String.toFloat str) 103 | 104 | 105 | badFloat : String -> Test 106 | badFloat str = 107 | test str <| \_ -> 108 | Expect.equal 109 | (Err ("could not convert string '" ++ str ++ "' to a Float")) 110 | (String.toFloat str) 111 | -------------------------------------------------------------------------------- /ios/FarmStatsTW.xcodeproj/xcshareddata/xcschemes/Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 80 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 101 | 107 | 108 | 109 | 110 | 112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /ios/FarmStatsTW/Images.xcassets/AppIcon.debug.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "size" : "20x20", 10 | "idiom" : "iphone", 11 | "filename" : "Icon-60.png", 12 | "scale" : "3x" 13 | }, 14 | { 15 | "idiom" : "iphone", 16 | "size" : "29x29", 17 | "scale" : "1x" 18 | }, 19 | { 20 | "idiom" : "iphone", 21 | "size" : "29x29", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "idiom" : "iphone", 26 | "size" : "29x29", 27 | "scale" : "3x" 28 | }, 29 | { 30 | "idiom" : "iphone", 31 | "size" : "40x40", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "idiom" : "iphone", 36 | "size" : "40x40", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "Icon.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "57x57", 47 | "idiom" : "iphone", 48 | "filename" : "Icon@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-60@2x.png", 55 | "scale" : "2x" 56 | }, 57 | { 58 | "size" : "60x60", 59 | "idiom" : "iphone", 60 | "filename" : "Icon-60@3x.png", 61 | "scale" : "3x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "20x20", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "size" : "20x20", 70 | "idiom" : "ipad", 71 | "filename" : "Icon-Small-40.png", 72 | "scale" : "2x" 73 | }, 74 | { 75 | "size" : "29x29", 76 | "idiom" : "ipad", 77 | "filename" : "Icon-Small.png", 78 | "scale" : "1x" 79 | }, 80 | { 81 | "idiom" : "ipad", 82 | "size" : "29x29", 83 | "scale" : "2x" 84 | }, 85 | { 86 | "idiom" : "ipad", 87 | "size" : "40x40", 88 | "scale" : "1x" 89 | }, 90 | { 91 | "idiom" : "ipad", 92 | "size" : "40x40", 93 | "scale" : "2x" 94 | }, 95 | { 96 | "size" : "50x50", 97 | "idiom" : "ipad", 98 | "filename" : "Icon-Small-50.png", 99 | "scale" : "1x" 100 | }, 101 | { 102 | "size" : "50x50", 103 | "idiom" : "ipad", 104 | "filename" : "Icon-Small-50@2x.png", 105 | "scale" : "2x" 106 | }, 107 | { 108 | "size" : "72x72", 109 | "idiom" : "ipad", 110 | "filename" : "Icon-72.png", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "size" : "72x72", 115 | "idiom" : "ipad", 116 | "filename" : "Icon-72@2x.png", 117 | "scale" : "2x" 118 | }, 119 | { 120 | "size" : "76x76", 121 | "idiom" : "ipad", 122 | "filename" : "Icon-76.png", 123 | "scale" : "1x" 124 | }, 125 | { 126 | "size" : "76x76", 127 | "idiom" : "ipad", 128 | "filename" : "Icon-76@2x.png", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "idiom" : "ipad", 133 | "size" : "83.5x83.5", 134 | "scale" : "2x" 135 | }, 136 | { 137 | "size" : "24x24", 138 | "idiom" : "watch", 139 | "filename" : "Icon-mdpi.png", 140 | "scale" : "2x", 141 | "role" : "notificationCenter", 142 | "subtype" : "38mm" 143 | }, 144 | { 145 | "size" : "27.5x27.5", 146 | "idiom" : "watch", 147 | "scale" : "2x", 148 | "role" : "notificationCenter", 149 | "subtype" : "42mm" 150 | }, 151 | { 152 | "size" : "29x29", 153 | "idiom" : "watch", 154 | "filename" : "Icon-Small@2x.png", 155 | "role" : "companionSettings", 156 | "scale" : "2x" 157 | }, 158 | { 159 | "size" : "29x29", 160 | "idiom" : "watch", 161 | "role" : "companionSettings", 162 | "scale" : "3x" 163 | }, 164 | { 165 | "size" : "40x40", 166 | "idiom" : "watch", 167 | "filename" : "Icon-Small-40@2x.png", 168 | "scale" : "2x", 169 | "role" : "appLauncher", 170 | "subtype" : "38mm" 171 | }, 172 | { 173 | "size" : "86x86", 174 | "idiom" : "watch", 175 | "scale" : "2x", 176 | "role" : "quickLook", 177 | "subtype" : "38mm" 178 | }, 179 | { 180 | "size" : "98x98", 181 | "idiom" : "watch", 182 | "scale" : "2x", 183 | "role" : "quickLook", 184 | "subtype" : "42mm" 185 | }, 186 | { 187 | "size" : "72x72", 188 | "idiom" : "ipad", 189 | "filename" : "Icon-hdpi.png", 190 | "unassigned" : true, 191 | "scale" : "1x" 192 | }, 193 | { 194 | "size" : "72x72", 195 | "idiom" : "ipad", 196 | "filename" : "Icon-xxhdpi.png", 197 | "unassigned" : true, 198 | "scale" : "2x" 199 | }, 200 | { 201 | "filename" : "Icon-ldpi.png", 202 | "unassigned" : true 203 | }, 204 | { 205 | "filename" : "Icon-xhdpi.png", 206 | "unassigned" : true 207 | }, 208 | { 209 | "filename" : "Icon-xxxhdpi.png", 210 | "unassigned" : true 211 | } 212 | ], 213 | "info" : { 214 | "version" : 1, 215 | "author" : "xcode" 216 | } 217 | } -------------------------------------------------------------------------------- /elm-stuff/packages/elm-lang/core/5.1.1/src/Regex.elm: -------------------------------------------------------------------------------- 1 | module Regex exposing 2 | ( Regex 3 | , regex, escape, caseInsensitive 4 | , HowMany(..), Match 5 | , contains, find, replace, split 6 | ) 7 | 8 | {-| A library for working with regular expressions. It uses [the 9 | same kind of regular expressions accepted by JavaScript](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions). 10 | 11 | # Create 12 | @docs Regex, regex, escape, caseInsensitive 13 | 14 | # Helpful Data Structures 15 | 16 | These data structures are needed to help define functions like [`find`](#find) 17 | and [`replace`](#replace). 18 | 19 | @docs HowMany, Match 20 | 21 | # Use 22 | @docs contains, find, replace, split 23 | 24 | -} 25 | 26 | import Maybe exposing (Maybe) 27 | import Native.Regex 28 | 29 | 30 | {-| A regular expression, describing a certain set of strings. 31 | -} 32 | type Regex = Regex 33 | 34 | 35 | {-| Escape strings to be regular expressions, making all special characters 36 | safe. So `regex (escape "^a+")` will match exactly `"^a+"` instead of a series 37 | of `a`’s that start at the beginning of the line. 38 | -} 39 | escape : String -> String 40 | escape = 41 | Native.Regex.escape 42 | 43 | 44 | {-| Create a Regex that matches patterns [as specified in JavaScript](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Writing_a_Regular_Expression_Pattern). 45 | 46 | Be careful to escape backslashes properly! For example, `"\w"` is escaping the 47 | letter `w` which is probably not what you want. You probably want `"\\w"` 48 | instead, which escapes the backslash. 49 | -} 50 | regex : String -> Regex 51 | regex = 52 | Native.Regex.regex 53 | 54 | 55 | 56 | {-| Make a regex case insensitive -} 57 | caseInsensitive : Regex -> Regex 58 | caseInsensitive = 59 | Native.Regex.caseInsensitive 60 | 61 | 62 | {-| Check to see if a Regex is contained in a string. 63 | 64 | contains (regex "123") "12345" == True 65 | contains (regex "b+") "aabbcc" == True 66 | 67 | contains (regex "789") "12345" == False 68 | contains (regex "z+") "aabbcc" == False 69 | -} 70 | contains : Regex -> String -> Bool 71 | contains = 72 | Native.Regex.contains 73 | 74 | 75 | {-| A `Match` represents all of the details about a particular match in a string. 76 | Here are details on each field: 77 | 78 | * `match` — the full string of the match. 79 | * `submatches` — a regex might have [subpatterns, surrounded by 80 | parentheses](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Using_Parenthesized_Substring_Matches). 81 | If there are N subpatterns, there will be N elements in the `submatches` list. 82 | Each submatch in this list is a `Maybe` because not all subpatterns may trigger. 83 | For example, `(regex "(a+)|(b+)")` will either match many `a`’s or 84 | many `b`’s, but never both. 85 | * `index` — the index of the match in the original string. 86 | * `number` — if you find many matches, you can think of each one 87 | as being labeled with a `number` starting at one. So the first time you 88 | find a match, that is match `number` one. Second time is match `number` two. 89 | This is useful when paired with `replace All` if replacement is dependent on how 90 | many times a pattern has appeared before. 91 | -} 92 | type alias Match = 93 | { match : String 94 | , submatches : List (Maybe String) 95 | , index : Int 96 | , number : Int 97 | } 98 | 99 | 100 | {-| `HowMany` is used to specify how many matches you want to make. So 101 | `replace All` would replace every match, but `replace (AtMost 2)` would 102 | replace at most two matches (i.e. zero, one, two, but never three or more). 103 | -} 104 | type HowMany = All | AtMost Int 105 | 106 | 107 | {-| Find matches in a string: 108 | 109 | findTwoCommas = find (AtMost 2) (regex ",") 110 | 111 | -- map .index (findTwoCommas "a,b,c,d,e") == [1,3] 112 | -- map .index (findTwoCommas "a b c d e") == [] 113 | 114 | places = find All (regex "[oi]n a (\\w+)") "I am on a boat in a lake." 115 | 116 | -- map .match places == ["on a boat", "in a lake"] 117 | -- map .submatches places == [ [Just "boat"], [Just "lake"] ] 118 | -} 119 | find : HowMany -> Regex -> String -> List Match 120 | find = 121 | Native.Regex.find 122 | 123 | 124 | {-| Replace matches. The function from `Match` to `String` lets 125 | you use the details of a specific match when making replacements. 126 | 127 | devowel = replace All (regex "[aeiou]") (\_ -> "") 128 | 129 | -- devowel "The quick brown fox" == "Th qck brwn fx" 130 | 131 | reverseWords = replace All (regex "\\w+") (\{match} -> String.reverse match) 132 | 133 | -- reverseWords "deliver mined parts" == "reviled denim strap" 134 | -} 135 | replace : HowMany -> Regex -> (Match -> String) -> String -> String 136 | replace = 137 | Native.Regex.replace 138 | 139 | 140 | {-| Split a string, using the regex as the separator. 141 | 142 | split (AtMost 1) (regex ",") "tom,99,90,85" == ["tom","99,90,85"] 143 | 144 | split All (regex ",") "a,b,c,d" == ["a","b","c","d"] 145 | -} 146 | split : HowMany -> Regex -> String -> List String 147 | split = 148 | Native.Regex.split 149 | --------------------------------------------------------------------------------