This file contains 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
interface ShopService { | |
void buy(); | |
void sell(); | |
} | |
interface DatabaseService { | |
void beginTransaction(); | |
void commit(); | |
void abort(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
This code parses a subset of JavaScript and detects usages of undeclared variables. | |
It's an example of a Parsec parser; it's by no means complete. | |
This source code primarily uses the do-syntax for writing the parser, | |
but that's not the only way to write code with Parsec. | |
This code was written in a hurry by Joakim Ahnfelt-Rønne during the meetup at 2014-21-10. | |
USAGE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.infopaq.research.flow.common; | |
import java.util.Arrays; | |
public class ByteId { | |
private final byte[] bytes; | |
public ByteId(byte[] bytes) { | |
this.bytes = bytes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void writeTag(int tag) throws SerializationException { | |
try { | |
if(tag < 128) { | |
stream.writeByte(tag - 128); | |
} else { | |
stream.writeInt(tag); | |
} | |
} catch(IOException e) { | |
throw new SerializationException(e); | |
} |
This file contains 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
data Sound | |
= Silence | |
| Audio AudioData | |
| Volume Double Sound | |
| Sequence Sound Sound | |
data SoundM a = SoundM Sound a | |
instance Monad SoundM where | |
return a = SoundM Silence a |
This file contains 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
// System.OpenCL.Private.Synchronization: | |
module System.OpenCL.Private.Synchronization ( | |
enqueueMarker, enqueueBarrier, enqueueWaitForEvents, waitForEvents | |
) where | |
// [..snip..] | |
waitForEvents :: [Event] -> IO () | |
waitForEvents events = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an implementation of Software Transactional Memory. | |
# The idea is that when a variable is first used in an atomic block, | |
# we save a snapshot of its current value and version. | |
# When we reach the end of the transaction, we lock all variables | |
# that have been read or written to inside the atomic block. If any | |
# of the variables we read has been changed from the outside, we | |
# reset the transaction and rerun it from the beginning. Otherwise | |
# we write the new values back into the shared memory with a new | |
# version. For each variable, we maintain information on what other | |
# variables have been updated to what versions at the same time, |
NewerOlder