-- Currently we write
do
eA <- reqSuccess <$> apiGetA
eB <- reqSuccess <$> apiGetB
dA <- holdDyn Nothing eA
dB <- holdDyn Nothing eB
dC <- f <$> dA <*> dB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Migrations | |
| ( dbMigrate | |
| , openAndMigrate | |
| ) where | |
| import Control.Exception | |
| import Control.Monad | |
| import Control.Monad.Except | |
| import Data.List qualified as List | |
| import Data.Map (Map) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SpyHttp where | |
| import Data.ByteString as BS | |
| import Network.HTTP.Client | |
| import Network.HTTP.Client as Http hiding (Proxy) | |
| import Network.HTTP.Client.Internal | |
| data HttpSpyEnv = HttpSpyEnv | |
| { manager :: Manager | |
| , incoming_ref :: IORef [Either ByteString ByteString] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Evidence for type equality | |
| type Eq<A, B> = { __typeEq__: Eq1<A, B>}; | |
| type Eq1<A, B> = [A, B] & typeof eqSymbol; | |
| const eqSymbol = Symbol('eqSymbol'); | |
| const runEq = <A, B>(eq: Eq<A, B>, a: A): B => a as any; | |
| type Fn<Args extends any[], R> = (...args: Args) => R; | |
| // Component messages, `A` is the result of evaluating the message in `update` | |
| type Msg<A = unknown> = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Ident = string; | |
| type Bindings = Record<Ident, unknown>; | |
| type List<T> = null | Cons<T>; | |
| type Cons<T> = { 0: T, 1: List<T> }; | |
| type JExp = unknown; | |
| type JVal = unknown; | |
| function Cons<T>(x: T, xs: List<T>): List<T> { | |
| return [x, xs]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type Optic<A, B> = | |
| | Iso<A, B> | |
| | Lens<A, B> | |
| | Prism<A, B> | |
| | Compose<A, B> | |
| ; | |
| export type Iso<A, B> = { | |
| apply: (a: A) => B; | |
| unapply: (b: B) => A; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Props = DivProps & { | |
| title: number; | |
| isActive: boolean; | |
| }; | |
| class Todo extends React.Component<Props> { | |
| render() { | |
| const { title, isActive, ...divProps } = this.props; | |
| return <div {...the<DivProps>(divProps) }> | |
| <input type="checkbox" value={isActive}/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Alternative sum types for typescript. Variants may be more convenient than unions | |
| // because they easier to manipulate (see `Mapped types`) | |
| // - [https://www.typescriptlang.org/docs/handbook/advanced-types.html](Mapped types) | |
| // - [https://github.com/natefaubion/purescript-variant] | |
| const variantSymbol = Symbol('Variant'); | |
| type Variant<T> = { 0: keyof T, 1: T[keyof T]; [variantSymbol]: T }; | |
| // Variant constructor | |
| function variant<T, K extends keyof T>(key: K, value: T[K]): Variant<T> { |