在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):MondayMorningHaskell/haskellings开源软件地址(OpenSource Url):https://github.com/MondayMorningHaskell/haskellings开源编程语言(OpenSource Language):Haskell 99.3%开源软件介绍(OpenSource Introduction):HaskellingsWelcome to Haskellings, an automated Haskell tutorial program (inspired by Rustlings). This program has dozens of small exercises where you can read about the basic ideas of the Haskell language and then implement some simple functions. Getting StartedTo use Haskellings, you must first have Haskell installed on your machine. The simplest way to do this is to install the Haskell Platform. Next, you'll need to clone this repository and then build the code using >> git clone https://github.com/MondayMorningHaskell/haskellings.git
>> stack build Note that you must clone it somewhere within your "home" directory (e.g. >> stack install
>> haskellings run Types1
... You can also run any >> stack exec -- haskellings run Types1 Using Nix (Experimental)Instead of running stack manually, you can use a nix shell to install the dependencies for you. To do this, install Nix. Then, when in the project's root directory, run After the build process, you should see a bash prompt like this: [nix-shell:~]$ This shell provides you with an environment that has GHC 8.10.4 and the These dependencies are only available within the Running ExercisesWithin the exercises directory, you can find sub-directories containing all the different exercise modules. You can run individual exercises with the >> haskellings run Types1 This will run the Initially, exercises will not compile. You'll want to open the file, read the information at the top, and then fill in the code as indicated by the You can re-run the exercise, and the output will let you know when you're done! If you're stuck, each exercise also has a hint you can see by running >> haskellings hint Types1
Fill in appropriate type signatures for the expressions at the bottom. Sometimes you might want to compile and run code you've written for one function without filling in the rest. When this happens, you can usually replace the question marks -- BEFORE:
subtract7 :: Int -> Int
subtract7 = ???
multiplyBy7 :: Int -> Int
multiplyBy7 = ???
-- AFTER:
subtract7 :: Int -> Int
subtract7 x = x - 7
multiplyBy7 :: Int -> Int
multiplyBy7 = undefined For example, after making the above change, you'll be able to run the tests for the Using the WatcherThe simplest way to ensure that you're doing exercises in order is to use the Watcher. You can invoke this with the command When you save your changes to the file, the Watcher will automatically re-compile and re-run the exercise, so you can see if you've completed it! Each exercise file has the following comment: -- I AM NOT DONE After the exercise is passing, you must delete this comment from the file and re-save to indicate to the Watcher that you are ready to move on to the next exercise. It will then automatically load and run your next task! You can also use hints within the Watcher! Just type 'hint' and press enter! >> haskellings watch
Couldn't compile : Expressions.hs
... (compilation output)
hint
Fill in numeric values in place of '???' for expression3 and expression4. Types of ExercisesThere are three different types of exercises. Compile-Only ExercisesThese are the most basic exercises. You'll see these with the more basic concepts, especially around create data types. In order to "pass" the exercise, you only have to edit the code so that the file compiles. Unit Test ExercisesThese represent the bulk of exercises. You'll see a Executable ExercisesThere are also a few executable exercises. These are most prevalent when you are learning about the When you use If it does not, you can run the executable using haskellings exec IO1 You can run this entering your own custom inputs. But to see why it is not "passing", you can enter in the Sample Inputs at the bottom of the file (if there are any). You should then compare your output to the Sample Output. It should usually (but not always) be a direct match. ContributingHaskellings is an open source project. If you've found a bug, have any suggestions for improvements or just want to help, let us know! Take a look at the CONTRIBUTING doc to learn how! ConfigurationIf you have a normal installation of the Haskell Platform, you probably do not need to read this section. Configuration happens automatically. But feel free to read on if you want to know more about the details and how you can customize them! In order to run exercises, Haskellings needs to know two paths on the local system.
Default ConfigurationBy default, Haskellings will search for these in particular locations. We search for the GHC path by starting at Stack's programs:
Then we do a breadth-first-search of these directories until we locate
Then to find the Stack snapshots directory, we use similar starting points:
These directories contain all your snapshots, each indicated by a hash value. Haskellings performs a BFS on these different hashes until it finds one contains
Custom ConfigurationIf you have Stack setup in such a way that these items are stored somewhere else on your system, you can customize these by creating a simple YAML file at the project root. This file should be called # haskellings/config.yaml
ghc_path: /bin/ghc-8.8.4
stack_package_db_path: /lib/stack_snapshots/8.8.4/pkgdb Note these paths should be absolute and not relative! You can also produce this file by running the >> haskellings configure
Please enter GHC Path (or leave blank for default): /bin/ghc-8.8.4
Please enter Stack package DB path (or leave blank): /lib/stack_snapshots/8.8.4/pkgdb Haskellings needs to be able to find the appropriate version of GHC to actually compile and run individual exercises. It also needs to find Stack package databases to enable dependencies. Right now, we only look for these in the default locations, such as Other Beginner MaterialAt Monday Morning Haskell, one of our core principles is that Haskell shouldn't be as hard to learn as people think it is. Accordingly, we have a wealth of other materials to help you get started learning the language!
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论