Skip to content

Instantly share code, notes, and snippets.

@pthariensflame
Last active December 18, 2015 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pthariensflame/5800291 to your computer and use it in GitHub Desktop.
Save pthariensflame/5800291 to your computer and use it in GitHub Desktop.
The signature of the `bracket` function in C#, Scala, Kotlin, Ceylon, Haskell, Agda, and Spellcode.

C#:

public static B Bracket<A, B>(Func<A> before, Action<A> after, Func<A, B> during);

Scala:

def bracket[A, B](before: => A, after: A => Unit)(during: A => B): B

Kotlin:

fun bracket<A, B>(before: () -> A, after: (A) -> Unit, during: (A) -> B): B

Ceylon:

shared B bracket<A, B>(A before(), void after(A))(B during(A));

Haskell:

bracket :: IO a -> (a -> IO ()) -> (a -> IO b) -> IO b

Agda:

bracket : {i j}  {A : Set i}  {B : A  Set j}  IO A  (A  IO ⊤)  ((x : A)  IO (B x))  IO (Σ[ x ∈ A ] B x)

Spellcode:

bracket :: forall i A B where (i :: Level) & (A :: Type i) & (B :: A -@ Total @> Type i) in A -@ Total @> (A -@ IO @> Top) -@ Total @> ((x : A) -@ IO @> B x) -@ IO @> (exists x where x :: A in B x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment