Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

translated part 1.2 'Types and Functions' #3

Merged
merged 3 commits into from
Sep 19, 2017

Conversation

s-km
Copy link
Contributor

@s-km s-km commented Sep 16, 2017

I tried to follow similar conventions as in category-the-essence-of-composition.md, but there are a bunch of different ways to translate the Haskell code snippets to Scala, so it'd be nice if we could make a short style guide or something to keep things consistent

ex 1 val fact = (n: Int) => (1 to n toList) product vs. val fact = (n: Int) => (1 to n).toList.product vs. val fact = (n: Int) => List.range(1, n).product vs. def fact(n: Int) = (1 to n).toList.product etc.

ex 2

fInt :: Integer -> ()
fInt x = ()
val fInt: BigInt => Unit = x => ()

................

fInt :: Integer -> ()
fInt _ = ()
val fInt: BigInt => Unit = _ => ()

vs

fInt :: Integer -> ()
fInt x = ()

fInt _ = ()
val fInt: BigInt => Unit = x => ()

val fInt: BigInt => Unit = _ => ()

@SystemFw SystemFw self-requested a review September 16, 2017 10:32
fact n = product [1..n]
```
```scala
val fact = (n: Int) => (1 to n toList) product
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally prefer to avoid postfix ops, so (1 to n).toList.product

@kailuowang
Copy link
Contributor

Shall we use "tut:silent" instead of "scala", for all the compilable code?

@s-km
Copy link
Contributor Author

s-km commented Sep 17, 2017

@kailuowang The only 'problem' I see with that is that you'd get inconsistent syntax highlighting with how we're currently doing things. Though, it'd be simple enough to just change tut target and source directory settings, and have something like this:

CT_from_Programmers.scala/
  ├── project/
  │   └── build.properties
  │   └── plugins.sbt
  ├── src/
  │   └── main/
  │       └── tut/
  │           └── file_with_tut:silent_tags1.md
  │           └── file_with_tut:silent_tags2.md
  │           └── file_with_tut:silent_tags3.md
  └── translations/
  │   └── tut_output_file_with_scala_tags1.md
  │   └── tut_output_file_with_scala_tags2.md
  │   └── tut_output_ile_with_scala_tags3.md
  └── .gitignore
  └── .travis.yml
  └── README.md
  └── build.sbt

@kailuowang
Copy link
Contributor

I wouldn't worry about the syntax highlighting in this repo. My plan is that after we finish we just going to use tut to compile the main/src/tut/*.md files and handover Bartosz the target md files or HTML files from Jekyll on top of that. After he manually edit in our sample code in his posts, it might loss syntax highlighting like the current haskell and c++ code.

@kailuowang kailuowang merged commit 703558c into typelevel:master Sep 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants