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
require 'stringio' | |
class ADT < Struct | |
def self.members() @members end | |
def self.add_member(c) | |
@members ||= [] | |
@members << c | |
@members.length - 1 | |
end | |
def self.data(*args) |
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
class HasStmt a where | |
class HasDef a where | |
class HasExpr a where | |
data Module = Module [ParsedDef] | |
data ParsedDef = ParsedDef (Definition ParsedStmt) SourcePos | |
data ParsedStmt = ParsedStmt (Statement ParsedDef ParsedStmt ParsedExpr) SourcePos | |
data ParsedExpr = ParsedExpr (Expr ParsedExpr) SourcePos |
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
{-#Language DeriveFunctor | |
, DeriveFoldable | |
, DeriveTraversable #-} | |
import Control.Applicative | |
import Data.Foldable | |
import Data.Traversable | |
import Prelude hiding (sum) |
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
source "http://rubygems.org" | |
gem "my_awesome_lib", :path => "../my_awesome_lib" | |
# or to use directly from a git repository: | |
# gem "my_awesome_lib", :git => "git://path/to/git/repo/my_awesome_lib.git", :branch => "1.0" | |
# or just use as a gem (perhaps from your very own gem source): | |
# gem "my_awesome_lib", ">= 1.0.0" |
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
#include "DetectDanger.h" | |
bool Detect_Ship_In_Danger(bool * const in_danger, | |
Position2D const detector1_pos, | |
Direction2D const detector1_ship_direction_time1, | |
Direction2D const detector1_ship_direction_time2, | |
Position2D const detector2_pos, | |
Direction2D const detector2_ship_direction_time1, | |
Direction2D const detector2_ship_direction_time2, | |
Position2D const hazard_pos, |
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
def arctan(n, x): | |
if x > 1.0: | |
return math.pi/2.0 - my_preferred_arctan_implementation(n, 1/x) | |
else: | |
return my_preferred_arctan_implementation(n, x) |
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
let result = do | |
account <- getAccount person | |
lastTransaction <- getLastTransaction account | |
getAmount lastTransaction | |
case result of | |
Nothing -> putStrLn "Oh noes!" | |
Just a -> putStrLn ("The amount was: " ++ show a) | |
-- Or really, I'd actually do this: |
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
{-#Language GeneralizedNewtypeDeriving #-} | |
module Language.TheExperiment.AST where | |
import Text.Parsec.Pos | |
import Language.TheExperiment.Type | |
data Literal = StringLiteral String | |
| CharLiteral Char | |
| IntegerLiteral Integer |
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
#ifndef MODULEA_H | |
#define MODULEA_H | |
#include "moduleB.h" | |
typedef struct | |
{ | |
... | |
} ModuleAType; |
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
import Data.FixedList -- this doesn't come with haskell, do a 'cabal install fixed-list' to install it | |
-- or get it from here: http://hackage.haskell.org/package/fixed-list-0.1.5 | |
-- more documentation on this library is here: http://hackage.haskell.org/packages/archive/fixed-list/0.1.5/doc/html/Data-FixedList.html | |
-- These are all built in haskell modules | |
import Control.Applicative | |
import Data.Foldable | |
import Prelude hiding (sum, concat) | |