forked from google-research/dex-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dan-zheng/tutorial-edits
Edit tutorial by @srush.
- Loading branch information
Showing
136 changed files
with
5,338 additions
and
5,329 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- arguments: [--color] | ||
- ignore: {name: "Use fmap"} |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
packages: dex.cabal | ||
|
||
source-repository-package | ||
type: git | ||
location: https://github.com/llvm-hs/llvm-hs | ||
tag: llvm-9 | ||
subdir: llvm-hs | ||
|
||
source-repository-package | ||
type: git | ||
location: https://github.com/llvm-hs/llvm-hs | ||
tag: llvm-9 | ||
subdir: llvm-hs-pure |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ name: dex | |
version: 0.1.0.0 | ||
author: Dougal Maclaurin | ||
maintainer: [email protected] | ||
license-file: LICENSE | ||
build-type: Simple | ||
|
||
flag cuda | ||
|
@@ -32,17 +33,22 @@ library | |
exposed-modules: Env, Syntax, Type, Inference, JIT, LLVMExec, | ||
Parser, Util, Imp, Imp.Embed, Imp.Optimize, | ||
PPrint, Algebra, Parallelize, Optimize, Serialize | ||
Actor, Cat, Flops, Embed, | ||
Actor, Cat, Embed, Export, | ||
RenderHtml, LiveOutput, Simplify, TopLevel, | ||
Autodiff, Interpreter, Logging, PipeRPC, CUDA, | ||
Autodiff, Interpreter, Logging, CUDA, | ||
LLVM.JIT, LLVM.Shims | ||
build-depends: base, containers, mtl, binary, bytestring, | ||
time, tf-random, llvm-hs-pure ==9.*, llvm-hs ==9.*, | ||
aeson, megaparsec >=8.0, warp, wai, filepath, | ||
parser-combinators, http-types, prettyprinter, text, | ||
blaze-html, cmark, diagrams-lib, ansi-terminal, | ||
transformers, directory, mmap, unix, | ||
process, primitive, store, dex-resources, temporary, | ||
build-depends: base, containers, mtl, bytestring, | ||
llvm-hs-pure, llvm-hs, | ||
-- Parsing | ||
megaparsec, parser-combinators, | ||
-- Text output | ||
prettyprinter, text, | ||
-- Portable system utilities | ||
filepath, directory, ansi-terminal, process, temporary, | ||
-- Serialization | ||
store, | ||
-- Notebook support | ||
warp, wai, blaze-html, aeson, http-types, cmark, binary | ||
if !os(darwin) | ||
exposed-modules: Resources | ||
hs-source-dirs: src/resources | ||
|
@@ -51,11 +57,12 @@ library | |
build-depends: dex-resources | ||
default-language: Haskell2010 | ||
hs-source-dirs: src/lib | ||
ghc-options: -Wall -fPIC | ||
ghc-options: -Wall -fPIC -threaded -optP-Wno-nonportable-include-path | ||
cxx-sources: src/lib/dexrt.cpp | ||
cxx-options: -std=c++11 -fPIC | ||
default-extensions: CPP, DeriveTraversable, TypeApplications, OverloadedStrings, | ||
TupleSections, ScopedTypeVariables, LambdaCase, PatternSynonyms | ||
TupleSections, ScopedTypeVariables, LambdaCase, PatternSynonyms, | ||
BlockArguments | ||
pkgconfig-depends: libpng | ||
if flag(cuda) | ||
include-dirs: /usr/local/cuda/include | ||
|
@@ -71,42 +78,33 @@ executable dex | |
main-is: dex.hs | ||
other-extensions: OverloadedStrings | ||
build-depends: dex, base, haskeline, prettyprinter, mtl, | ||
optparse-applicative, unix, store, bytestring, directory | ||
optparse-applicative, ansi-wl-pprint, | ||
unix, store, bytestring, directory | ||
if os(darwin) | ||
build-depends: dex-resources | ||
default-language: Haskell2010 | ||
hs-source-dirs: src | ||
default-extensions: CPP, LambdaCase | ||
default-extensions: CPP, LambdaCase, BlockArguments | ||
ghc-options: -optP-Wno-nonportable-include-path | ||
if flag(optimized) | ||
ghc-options: -O3 | ||
else | ||
ghc-options: -O0 | ||
|
||
foreign-library Dex | ||
type: native-shared | ||
other-modules: API | ||
build-depends: base, dex, dex-resources, mtl | ||
hs-source-dirs: src/foreign | ||
c-sources: src/foreign/rts.c | ||
other-modules: Dex.Foreign.API, Dex.Foreign.Util, Dex.Foreign.JIT | ||
, Dex.Foreign.Context, Dex.Foreign.Serialize | ||
build-depends: base, mtl, containers, llvm-hs, dex, dex-resources | ||
if os(darwin) | ||
build-depends: dex-resources | ||
hs-source-dirs: src/ | ||
c-sources: src/Dex/Foreign/rts.c | ||
cc-options: -std=c11 -fPIC | ||
ghc-options: -Wall -fPIC | ||
default-language: Haskell2010 | ||
default-extensions: TypeApplications, ScopedTypeVariables, LambdaCase | ||
if flag(optimized) | ||
ghc-options: -O3 | ||
else | ||
ghc-options: -O0 | ||
|
||
Test-Suite test-dex | ||
type: exitcode-stdio-1.0 | ||
main-is: PropTests.hs | ||
build-depends: dex, base, prettyprinter, containers, | ||
hedgehog, microlens-platform, mtl | ||
other-modules: GenExpr, TestPass | ||
ghc-options: -Wall -fPIC -optP-Wno-nonportable-include-path | ||
default-language: Haskell2010 | ||
hs-source-dirs: tests | ||
ghc-options: cbits/libdex.so | ||
-Wall | ||
default-extensions: TypeApplications, ScopedTypeVariables, LambdaCase, | ||
BlockArguments | ||
if flag(optimized) | ||
ghc-options: -O3 | ||
else | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
|
||
include "plot.dx" | ||
|
||
UnitInterval = Float | ||
|
||
bmIter : (Key & Float & Float & UnitInterval) -> (Key & Float & Float & UnitInterval) = | ||
\(key, y, sigma, t). | ||
(kDraw, kL, kR) = splitKey3 key | ||
t' = abs (t - 0.5) | ||
y' = sigma * randn kDraw * (0.5 - t') | ||
key' = select (t > 0.5) kL kR | ||
(key', y + y', sigma / sqrt 2.0, t' * 2.0) | ||
def bmIter ((key, y, sigma, t):(Key & Float & Float & UnitInterval)) : | ||
(Key & Float & Float & UnitInterval) = | ||
[kDraw, kL, kR] = splitKey key | ||
t' = abs (t - 0.5) | ||
y' = sigma * randn kDraw * (0.5 - t') | ||
key' = select (t > 0.5) kL kR | ||
(key', y + y', sigma / sqrt 2.0, t' * 2.0) | ||
|
||
sampleBM : Key -> UnitInterval -> Float = | ||
\key t. | ||
(_, y, _, _) = fold (key, 0.0, 1.0, t) \i:(Fin 10). bmIter | ||
y | ||
def sampleBM (key:Key) (t:UnitInterval) : Float = | ||
(_, y, _, _) = fold (key, 0.0, 1.0, t) \i:(Fin 10). bmIter | ||
y | ||
|
||
xs = linspace (Fin 1000) 0.0 1.0 | ||
ys = map (sampleBM (newKey 0)) xs | ||
|
||
-- :plot zip xs ys | ||
-- > <html output> | ||
:html showPlot $ xyPlot xs ys | ||
> <html output> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.