Skip to content

Commit 236139d

Browse files
committed
Merge with NewMech
2 parents e7ea003 + de6361c commit 236139d

File tree

18 files changed

+833
-181
lines changed

18 files changed

+833
-181
lines changed

Book/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore the built files
2+
build/

Book/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
run :
3+
python3 build.py

Book/build.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def build_index(sources):
109109
("Differential calculus", "Physics/src/Calculus/DifferentialCalc.lhs"),
110110
("Integral calculus", "Physics/src/Calculus/IntegralCalc.lhs"),
111111
("Plotting graphs", "Physics/src/Calculus/VisVerApp.lhs"),
112+
("Syntax trees", "Physics/src/Calculus/SyntaxTree.lhs"),
112113
]),
113114
("Linear algebra", [
114115
("Vectors", "Physics/src/Vector/Vector.lhs")
@@ -123,6 +124,19 @@ def build_index(sources):
123124
("Testing of Quantities",
124125
"Physics/src/Dimensions/Quantity/Test.lhs"),
125126
("Usage", "Physics/src/Dimensions/Usage.lhs"),
127+
]),
128+
("Vectors", [
129+
("Vector", "Physics/src/Vector/Vector.lhs")
130+
]),
131+
("Calculus", [
132+
("Introduction", "Physics/src/Calculus/Intro.lhs"),
133+
("Function expressions", "Physics/src/Calculus/FunExpr.lhs"),
134+
("Differential calculus", "Physics/src/Calculus/DifferentialCalc.lhs"),
135+
("Integral calculus", "Physics/src/Calculus/IntegralCalc.lhs"),
136+
("Visualization, Verification, and Application", "Physics/src/Calculus/VisVerApp.lhs"),
137+
]),
138+
("Newtonian Mechanics", [
139+
("Single particle mechanics", "Physics/src/NewtonianMechanics/SingleParticle.lhs")
126140
])
127141
# ("Examples", [
128142
# ("Gungbräda", "Physics/src/Examples/Gungbraeda.lhs"),

Book/includes/type.html

Lines changed: 0 additions & 63 deletions
This file was deleted.

Book/test.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

Physics/Hatlab/package.cache

40 Bytes
Binary file not shown.

Physics/Hatlab/package.cache.lock

Whitespace-only changes.

Physics/_w

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
> {-# LANGUAGE GADTs #-}
2+
> module Body.TypedVectors where
3+
4+
In order to do some physics we have to imbue our vectors with a dimension.
5+
6+
> import Vector.Vector as V
7+
> import Dimensions.ValueLevel as Val
8+
9+
> data TypedVector = TV Vector2 Dim
10+
11+
> velocity :: TypedVector
12+
> velocity = TV (V2 0 0) (Val.length `Val.div` time)
13+
14+
> instance Show TypedVector where
15+
> show (TV vec dim) = show (V.magnitude vec) ++ " " ++ show dim
16+
17+
We can add vectors together
18+
19+
> data TVOps where
20+
> Add :: TypedVector -> TypedVector -> TVOps
21+
> Scale :: Scalar -> TypedVector -> TVOps
22+
23+
24+
> add :: TypedVector -> TypedVector -> TVOps
25+
> add = Add
26+
27+
> eval :: TVOps -> IO TypedVector
28+
> eval (Add (TV vec1 dim1) (TV vec2 dim2)) = case dim1 == dim2 of
29+
> True -> return $ TV (V.add vec1 vec2) dim1
30+
> False -> error "Dimensions are different"
31+
> eval (Scale s (TV vec dim)) = return $ TV (V.scale s vec) dim
32+
33+
34+

Physics/app/Main.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module Main where
22

3-
--import Lib
4-
53
main :: IO ()
64
main = undefined

Physics/package.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ extra-source-files:
1717
# To avoid duplicated efforts in documentation and dealing with the
1818
# complications of embedding Haddock markup inside cabal files, it is
1919
# common to point users to the README.md file.
20-
description: Please see the README on Github at <https://github.com/githubuser/Physics#readme>
20+
description: Please see the README on Github at <https://github.com/githubuser/Physics#readme>
2121

2222
dependencies:
2323
- base >= 4.7 && < 5
2424
- Hatlab
25+
- containers
26+
- pretty-tree
2527
- QuickCheck
2628
- numtype-dk
2729

0 commit comments

Comments
 (0)