onfocus: send UpdateLocationSuggesion
UpdateLocationSuggesion
- if we already have geolocation: send UpdateLocationSuggesions
- if we don't: send GetLocation
UpdateLocationSuggesions
- if mobile and empty input and LocationSuccess:
| module type Monad = | |
| sig | |
| type 'a t | |
| val map : ('a -> 'b) -> 'a t -> 'b t | |
| val apply : ('a -> 'b) t -> 'a t -> 'b t | |
| val pure : 'a -> 'a t | |
| val bind : 'a t -> ('a -> 'b t) -> 'b t | |
| end | |
| module Option : Monad with type 'a t = 'a option = struct |
| let (<|) = ('a => 'b, 'a) => 'b; // purescript and haskell use ($) | |
| let (|>) = ('a, 'a => 'b) => 'b; // purescript uses (#) | |
| let compose: ('b => 'c, 'a => 'b, 'a) => 'c; | |
| let (<<) = compose; // purescript uses (<<<), haskell uses (.) | |
| let composeFlipped: ('a => 'b, 'b => 'c, 'a) => 'c; | |
| let (>>) = composeFlipped; // purescript uses (>>>) |
| open Typeclasses; | |
| // a binary search tree is a binary tree that holds order-able members and | |
| // keeps lesser values on the left and greater or equal values on the right | |
| module Make = (Order: Ord) => { | |
| type t = | |
| | Empty | |
| | Node(t, Order.t, t); | |
| // O(log n) operation to add a new value in a valid position in the tree |
| let onClick = _ => send(ToggleMenu); | |
| // The following is how elm-ui does it (translated to JSX) | |
| // Pros: | |
| // - Relatively easy to understand | |
| // - `Button` is any normal component | |
| // - It's obvious that the container element can have all of the normal | |
| // layout props and decoration attributes | |
| // | |
| // Cons: |
| [%do Future] | |
| do { | |
| user <- getUser("some_user_id") | |
| orders = user.orders | |
| firstOrderId <- orders |> List.head |> Future.fromOption | |
| order <- getOrder(firstOrderId) | |
| pure(user.firstName ++ " ordered a " ++ order.productName) | |
| }; | |
| Future.( |
| // I'm not entirely sure what this thing is. It feels powerful and expressive | |
| // and like you can compose things. Not sure what it would be useful for, though. | |
| // Maybe you could make a UI to build arbitrarily complex predicate functions | |
| // for filtering collections of data? | |
| module RuleEngine = { | |
| type t('a) = | |
| | Rule('a) | |
| | Not(t('a)) | |
| | And(t('a), t('a)) |
| [@bs.module "react-native-calendario"] | |
| external calendar: ReasonReact.reactClass = "default"; | |
| type dateRange = { | |
| startDate: Js.Date.t, | |
| endDate: option(Js.Date.t), | |
| }; | |
| let dateRangeFromJS = range => { | |
| startDate: range##startDate, |
| /** | |
| * t-first and t-last examples when working with `Future.t(Result.t('a, 'e))` | |
| **/ | |
| // `Future` and `Result` are both t-last | |
| getJSON("some/url") | |
| |> Future.map(Result.flatMap(decodeUser)) | |
| |> Future.map(Result.mapWithDefault(DataFailed, v => ShowData(v))) | |
| |> Future.tap(send); |
The Elm Architecture, specialized for games.
Key points: