Skip to content

Commit

Permalink
Add the new format for the 102 codelab
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaimaruseac committed Dec 20, 2021
1 parent b273619 commit ffbb4b3
Show file tree
Hide file tree
Showing 25 changed files with 1,675 additions and 0 deletions.
45 changes: 45 additions & 0 deletions haskell_102/codelab/00_setup/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

.DEFAULT_GOAL := run
.PHONY: repl run clean

TARGET = codelab

TOOL = .tool
REPL = .repl_tool
BUILD_GENERATED = dist dist-newstyle .stack-work stack.yaml.lock $(TOOL) $(REPL)

repl: $(REPL)
@`cat $(REPL)` :$(TARGET)

run: $(TOOL)
@`cat $(TOOL)` run $(TARGET)

clean:
@$(RM) -r $(BUILD_GENERATED)

#
# Private rules to check which toolchain is available
#

$(TOOL):
@([[ -e `which stack` ]] && echo stack > $(TOOL) || true)
@([[ -s $(TOOL) ]] || ([[ -e `which cabal` ]] && echo cabal > $(TOOL)) || true)
@([[ -s $(TOOL) ]] || (cat setup.md && false))

$(REPL):
@([[ -e `which stack` ]] && echo stack > $(TOOL) || true)
@([[ -s $(REPL) ]] || ([[ -e `which cabal` ]] && echo cabal repl > $(REPL)) || true)
@([[ -s $(REPL) ]] || (cat setup.md && false))
16 changes: 16 additions & 0 deletions haskell_102/codelab/00_setup/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

import Distribution.Simple
main = defaultMain
32 changes: 32 additions & 0 deletions haskell_102/codelab/00_setup/codelab.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Copyright 2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

name: codelab
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10

executable codelab
hs-source-dirs: src
default-language: Haskell2010
main-is: Main.hs
build-depends:
base >=4.11 && <4.15

executable solution
hs-source-dirs: src
default-language: Haskell2010
main-is: Main.hs
build-depends:
base >=4.11 && <4.15
16 changes: 16 additions & 0 deletions haskell_102/codelab/00_setup/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
============================================

HASKELL 102

============================================

If you are reading this text, probably you don't have Haskell environment setup
on your system. This should give you enough instructions to install it.

First, note that there are two different ways to get Haskell installed:

1. using [Stack](https://docs.haskellstack.org/en/stable/README/)
2. getting the [Haskell Platform](https://www.haskell.org/platform/)

This course is not taking any side, you are free to install either of these. The
links above point to the install pages for either of the toolchains.
23 changes: 23 additions & 0 deletions haskell_102/codelab/00_setup/src/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Copyright 2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

module Main where

main :: IO ()
main = do
putStrLn "============================================"
putStrLn ""
putStrLn "Haskell toolchain is installed! All is good."
putStrLn ""
putStrLn "============================================"
17 changes: 17 additions & 0 deletions haskell_102/codelab/00_setup/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resolver: lts-14.25
packages:
- .
36 changes: 36 additions & 0 deletions haskell_102/codelab/01_mastermind/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

.PHONY: run clean

TARGET = codelab
ARGS = solve

TOOL = .tool
BUILD_GENERATED = dist dist-newstyle .stack-work stack.yaml.lock $(TOOL)

run: $(TOOL)
@`cat $(TOOL)` run $(TARGET) $(ARGS)

clean:
@$(RM) -r $(BUILD_GENERATED)

#
# Private rules to check which toolchain is available
#

$(TOOL):
@([[ -e `which stack` ]] && echo stack > $(TOOL) || true)
@([[ -s $(TOOL) ]] || ([[ -e `which cabal` ]] && echo cabal > $(TOOL)) || true)
@([[ -s $(TOOL) ]] || (cat setup.md && false))
16 changes: 16 additions & 0 deletions haskell_102/codelab/01_mastermind/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

import Distribution.Simple
main = defaultMain
58 changes: 58 additions & 0 deletions haskell_102/codelab/01_mastermind/codelab.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
-- Copyright 2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

name: codelab
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10

executable codelab
hs-source-dirs: src
default-language: Haskell2010
main-is: Main.hs
other-modules:
Code
, Color
, ColorMap
, Do
, ErrorOr
, Game
, Internal
, Tests
build-depends:
base >=4.11 && <4.15
, ansi-terminal >= 0.8.0.4
, containers >= 0.6.0.1
, optparse-applicative >= 0.14.3.0
, random >= 1.1

executable solution
hs-source-dirs: src
default-language: Haskell2010
main-is: Main.hs
other-modules:
CodeSolution
, ColorSolution
, ColorMapSolution
, DoSolution
, ErrorOrSolution
, Game
, Internal
, Tests
build-depends:
base >=4.11 && <4.15
, ansi-terminal >= 0.8.0.4
, containers >= 0.6.0.1
, optparse-applicative >= 0.14.3.0
, random >= 1.1
16 changes: 16 additions & 0 deletions haskell_102/codelab/01_mastermind/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
============================================

HASKELL MTV 102

============================================

If you are reading this text, probably you don't have Haskell environment setup
on your system. This should give you enough instructions to install it.

First, note that there are two different ways to get Haskell installed:

1. using [Stack](https://docs.haskellstack.org/en/stable/README/)
2. getting the [Haskell Platform](https://www.haskell.org/platform/)

This course is not taking any side, you are free to install either of these. The
links above point to the install pages for either of the toolchains.
Loading

0 comments on commit ffbb4b3

Please sign in to comment.