News aggregator

ANNOUNCE: buildable-0.1.0.0

haskell-cafe - Mon, 09/08/2014 - 2:32pm
Have you ever wanted to deal with the builders for various data types in a polymorphic/overloaded fashion? I'm needing to do so and couldn't find any existing code that did so, so I decided to rectify this: http://hackage.haskell.org/package/buildable As a (very contrived) example: λ> build ((365 :: Dec Int) <| fromValue (Char7 ' ') |> (365 :: BigEndian Int16) |> (" omega=
Categories: Offsite Discussion

Working with haskell in school

Haskell on Reddit - Mon, 09/08/2014 - 10:29am

So im a beginner with haskell and im currently working on an assignment with haskell in school and i have gotten stuck at this 5:

The assignments are here

I havent found anything on how to do it so i would love to get any help i can get.

I dont want you do to it for me i just want some help so i can solve it on my own

And something on assignment 5.1 would be great too

*edit: Cleaned up a bit and added a link to the assignment

submitted by Fassticman
[link] [4 comments]
Categories: Incoming News

The GHC Team: Haskell Implementors Workshop 2014 videos available!

Planet Haskell - Mon, 09/08/2014 - 9:55am

Without further ado, here's the ​HIW 2014 Youtube Playlist (kindly provided by Malcolm Wallace)

Categories: Offsite Blogs

introspection at runtime

Haskell on Reddit - Mon, 09/08/2014 - 9:41am

Can someone explain me why it is impossible to introspect into a function at runtime in Haskell?

submitted by felipeZ
[link] [6 comments]
Categories: Incoming News

FFI question

haskell-cafe - Mon, 09/08/2014 - 8:11am
Hello, I need memory refreshing about FFI because I need to fix a bug (plus I got down a rat hole because of Ukraine war :-(). Following a snippet of something I wrote:
Categories: Offsite Discussion

Jan Stolarek: Promoting functions to type families in Haskell

Planet Haskell - Mon, 09/08/2014 - 5:02am

It’s been very quiet on the blog these past few months not because I’m spending less time on functional programming but precisely for the opposite reason. Since January I’ve been working together with Richard Eisenberg to extend his singletons library. This work was finished in June and last Friday I gave a talk about our research on Haskell Symposium 2014. This was the first time I’ve been to the ICFP and Haskell Symposium. It was pretty cool to finally meet all these people I know only from IRC. I also admit that the atmosphere of the conference quite surprised me as it often felt like some sort of fan convention rather than the biggest event in the field of functional programming.

The paper Richard and I published is titled “Promoting Functions to Type Families in Haskell”. This work is based on Richard’s earlier paper “Dependently typed programming with singletons” presented two years ago on Haskell Symposium. Back then Richard presented the singletons library that uses Template Haskell to generate singleton types and functions that operate on them. Singleton types are types that have only one value (aside from bottom) which allows to reason about runtime values during compilation (some introduction to singletons can be found in this post on Richard’s blog). This smart encoding allows to simulate some of the features of dependent types in Haskell. In our current work we extended promotion capabilities of the library. Promotion is only concerned with generating type-level definitions from term-level ones. Type-level language in GHC has become quite expressive during the last couple of years but it is still missing many features available in the term-level language. Richard and I have found ways to encode almost all of these missing features using the already existing type-level language features. What this means is that you can write normal term-level definition and then our library will automatically generate an equivalent type family. You’re only forbidden from using infinite terms, the do-notation, and decomposing String literals to Chars. Numeric literals are also very problematic and the support is very limited but some of the issues can be worked around. What is really cool is that our library allows you to have partial application at the type level, which GHC normally prohibits.

You can learn more by watching my talk on YouTube, reading the paper or the singletons documentation. Here I’d like to add a few more information that are not present in the paper. So first of all the paper was concerned only with promotion and didn’t say anything about singletonization. But as we enabled more and more language constructs to be promoted we also made them singletonizable. So almost everything that can be promoted can also be singletonized. The most notable exception to this rule are type classes, which are not yet implemented at the moment.

An interesting issue was raised by Adam Gundry in a question after the talk: what about difference between lazy term-level semantics and strict type-level semantics? You can listen to my answer in the video but I’ll elaborate some more on this here. At one point during our work we were wondering about this issue and decided to demonstrate an example of an algorithm that crucially relies on laziness to work, ie. fails to work with strict semantics. I think it’s not straightforward to come up with such an algorithm but luckily I recalled the backwards state monad from Philip Wadler’s paper “The essence of functional programming”1. Bind operator of that monad looks like this (definition copied from the paper):

m `bindS` k = \s2 -> let (a,s0) = m s1 (b,s1) = k a s2 in  (b,s0)

The tricky part here is that the output of call to m becomes input to call to k, while the output of call to k becomes the input of m. Implementing this in a strict language does not at all look straightforward. So I promoted that definition expecting it to fail spectacularly but to my surprised it worked perfectly fine. After some investigation I understood what’s going on. Type-level computations performed by GHC are about constraint solving. It turns out that GHC is able to figure out in which order to solve these constraints and get the result. It’s exactly analogous to what happens with the term-level version at runtime: we have an order of dependencies between the closures and there is a way in which we can run these closures to get the final result.

All of this work is a small part of a larger endeavour to push Haskell’s type system towards dependent types. With singletons you can write type-level functions easily by writing their definitions using the term-level language and then promoting these definitions. And then you can singletonize your functions to work on singleton types. There were two other talks about dependent types during the conference: Stephanie Weirich’s “Depending on Types” keynote lecture during ICPF and Richard’s “Dependent Haskell” talk during Haskell Implementators Workshop. I encourage everyone interested in Haskell’s type system to watch both of these talks.

  1. The awful truth is that this monad does not really work with the released version of singletons. I only realized that when I was writing this post. See issue #94 on singletons bug tracker.
Categories: Offsite Blogs

ANNOUNCE: New Hackage release -LargeCardinalHierarchy-0.0.1

General haskell list - Sun, 09/07/2014 - 11:25pm
Shalom Fellow Haskellers, I just uploaded my first documented Hackage release, the LargeCardinalHierarchy.hs package. I wrote this program four years ago during my junior year of university. It is a simple transfinite cardinal arithmetic library for all large cardinals listed on the following Wikipedia page: http://en.wikipedia.org/wiki/List_of_large_cardinal_properties The documentation was generated using Haddock 2.11.0 and the source code was written under GHC 6.8.2. http://hackage.haskell.org/package/LargeCardinalHierarchy-0.0.1/src/LargeCardinalHierarchy.html Best, Stephen E. A. Britton _______________________________________________ Haskell mailing list Haskell< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell
Categories: Incoming News

A Netwire 5 Tutorial

Haskell on Reddit - Sun, 09/07/2014 - 10:34pm

I tried my hand at writing a tutorial for working with Netwire 5, GLFW, and OpenGL (primarily geared at the Netwire side). Some links:

Tutorial, and the GitHub referenced (and linked) in the post.

Any sort of feedback would be greatly appreciated -- grammatical mistakes, lack of clarity, being just plain run about a piece of my logic or code, anything. I want to get better at this kind of thing so I can give back to the community. Thanks for your time.

submitted by crockeo
[link] [4 comments]
Categories: Incoming News

Neil Mitchell: Shake in the wild

Planet Haskell - Sun, 09/07/2014 - 3:02pm

Summary: I spotted a few things using Shake, which I had nothing to do with.

In the past few days I have come across several things using the Shake build system. I wasn't involved in any of them, and haven't (yet) tried any of them out, but they certainly look cool.

ToolCabal

Tibor Bremer from Utrecht University gave a talk at the Haskell Implementors Workshop 2014 about his ToolCabal project. This project replaces the "build a package" part of Cabal with something more flexible, supporting multiple simultaneous targets and more flexible preprocessors - all built on top of Shake. It doesn't attempt to tackle dependency resolution yet. There is a video of the talk:

<iframe allowfullscreen="allowfullscreen" frameborder="0" height="315" src="https://www.youtube.com/embed/VUyIu2T1Qss" width="420"></iframe>

Samplecount

The folks at Samplecount have written several Shake based things. None are yet on Hackage, so I suspect they are somewhat prototypes, but they look like they're already used quite seriously.

  • shake-cabal-build to make it easier to build your Shake build systems with Cabal. Shake build systems need to be compiled with GHC, for which I usually use ghc --make, but this project explains how to get things building with Cabal - important if your build system pulls in other libraries.
  • shake-language-c is a project to simplify building C/C++ projects with Shake. From the docs:

shake-language-c is a cross-platform build system based on the Shake Haskell library. The focus is on cross-compilation of C, C++ and Objective C source code to various target platforms. Currently supported target platforms are iOS, Android NDK, Google Portable Native Client, MacOS X, Linux and Windows (MinGW). Supported host platforms are MacOS X, Linux and Windows.

  • methcla is their mobile sound engine, which is built using this Shake script, which (unsurprisingly) uses shake-language-c and shake-cabal-build.
Categories: Offsite Blogs

Edward Z. Yang: Haskell Implementor’s Workshop ’14

Planet Haskell - Sun, 09/07/2014 - 7:05am

This year at ICFP, we had some blockbuster attendance to the Haskell Implementor's Workshop (at times, it was standing room only). I had the pleasure of presenting the work I had done over the summer on Backpack.

You can grab the slides or view the presentation itself (thank you ICFP organizers for being incredibly on-the-ball with videos this year!) The talk intersects a little bit with my blog post A taste of Cabalized Backpack, but there are more pictures, and I also emphasize (perhaps a little too much) the long term direction we are headed in.

There were a lot of really nice talks at HiW. Here are some of my personal highlights:

Categories: Offsite Blogs

Lambdaheads - Wed 10.9.2014 - Functional Programming Vienna

Haskell on Reddit - Sun, 09/07/2014 - 3:21am

Dear Friends of Functional Programming!

I'd like to announce the monthly meeting of the Lambdaheads (https://metalab.at/wiki/Lambdaheads), a functional programming group based in Vienna. We will meet at the Metalab library in Rathausstraße 6, 1010 Vienna at 19:30.

I will prepare a talk on Prisms - because I did not manage to talk about Prisms last time.

If you are interested in functional programming, be it Haskell or a different language come and join us for a nice evening.

submitted by epsilonhalbe
[link] [comment]
Categories: Incoming News

Why does David Turner say type classes were a bad idea?

Haskell on Reddit - Sat, 09/06/2014 - 6:10pm

At the end of this talk, David Turner states that he thinks type classes were a mistake to include in Haskell, but doesn't elaborate. (I'm still a Haskell beginner so I don't quite get the 'joke' that the audience does).

I've done a bit of searching but most results I get explain how to use type classes and not so much what the problems with them might be. This is one article I found that I think touches on some issues:

http://degoes.net/articles/principled-typeclasses/

submitted by D_duck
[link] [96 comments]
Categories: Incoming News

Mike Izbicki: Getting started with GitHub, vim, and bash

Planet Haskell - Sat, 09/06/2014 - 6:00pm
Getting started with GitHub, vim, and bash posted on 2014-09-07 by Rashid Goshtasbi and Kyler Rynear

Learning to use git, vim, and bash was hard for us. These tools are so different than the tools we used when we first learned to program. And they’re confusing! But our professor made us use them… and eventually… after we learned the tools… we discovered that we really like them! So we’ve put together a simple video guide to help you learn and enjoy these tools too. We did this as part of the CS100 open source software development class at UC Riverside.

Click here to watch the full playlist on YouTube.

Getting Started with GitHub <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/bap-NSjgPFg?rel=0&amp;vq=hd1080" width="697.6"></iframe>

This video shows you step by step how to create an account on GitHub. Then we see how to create our first repository called test, and transfer it from GitHub onto our local machine using the git clone command.

Creating a file, pushing to GitHub, and pulling from GitHub <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/UrLkCZaXg9o?rel=0&amp;vq=hd1080" width="697.6"></iframe>

How do we create files and upload them to GitHub? The touch <filename> command will create an empty file for you. The vim <filename> command will open a file in an advanced text editor that we talk about farther down the page. The git push command sends these files from your local machine up to GitHub, and the git pull command downloads files from GitHub and saves them to your local computer.

Branches <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/E8-hUsR7IXA?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Branches let you work on files without messing up your original code. When you finish your changes, you can merge them into the master branch. This is the best part of version control.

Tags <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/WKG1u4Y_f3s?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Most programs have different versions, for example: 1.0, 1.1, 1.2, 2.1 and 2.2.1. The git tag command let’s you create these versions. They’re just like a checkpoint in a Mario game!

Forking & Pull Requests <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/tTnL84EvJTM?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Let’s say you want to contribute to an open source project, but you don’t have permission. In order to contribute to someone else’s repository, you must first “fork” it to create a repo that you do have push permission on. Then you issue a pull request through the GitHub website. This tells the owner of the original repo that you’ve made some changes they can incorporate.

The README.md file <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/4UTSEKzsSvM?rel=0&amp;vq=hd1080" width="697.6"></iframe>

README.md files are how you document your projects. The README.md should explain your program, give installation instructions, and list known bugs. Basically, it explains to someone else who has absolutely no idea what your program does or how to code, but it enables the user to understand the concepts and basic directions to execute your program. The .md extension at the end of the filename indicates that the file uses markdown formatting. This is a simple way to create nice looking documentation.

Learning vim

vim is an advanced text editor for Unix operating systems. It’s powerful, but all the commands are intimidating for first time users. Even though it’s hard to get used to at first, these videos will help you learn some of the basic commands and get comfortable with vim.

Getting Started <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/szTtE60fIt8?rel=0&amp;vq=hd1080" width="697.6"></iframe>

It was difficult at first trying to transverse my code while using vim. I was so used to being able to use my mouse and simply click where I wanted to go. There are many ways to maneuver inside of vim. Some may just use the h,j,k,l, up, down, left, right arrow keys, or the w, e, b keys to move. You can also press gg to go to the top of the code, G to go to the bottom of it, and (any number)G to go to the line number typed before the capital G.)

Cutting, copying, and pasting took a while to get used to when using vim. Sometimes there was something I wanted in my code that was in the instructions for the assignment. In order to paste I would use the p command, but I could not paste things from outside of vim into it. If I had something copied outside of vim, then to paste it into vim I would right click and just click paste. This would paste it wherever the cursor currently is. If you right click to copy, then it will not affect what is copied by using the commands y to copy or the commands d or x to cut. If those commands are used, the just clicking p will paste them. There are other ways to store more than one thing while copying or cutting, but these two ways were the most helpful as I learned how to use vim.

Another personal favorite features of vim, are the shift-a (takes you to the end of the line and into insert mode) and the shift-i (takes you to the beginning of the line and into insert mode) command. You can also press a to append after the cursor position, as well as i to insert before the current cursor position

vim also allows you to use the v or shift-v keys to highlight certain text or lines of code. You can then use other vim commands such as the copy, paste and delete keys to perform your needed actions.

Indentation <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/uuztdE_gixs?rel=0&amp;vq=hd1080" width="697.6"></iframe>

At first it felt very time consuming to indent multiple lines. I felt this way until I found about the V command. V lets users highlight a line and pressing up or down can highlight as many lines as they desire. All that was left to do was to type > after everything I wanted to indent was highlighted and it all would indented once to the right. Typing < would instead indent it to the left if I ever wanted to do that.

Deletion <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/x0BMbS2kWYc" width="697.6"></iframe>

There are two commands for deleting single character. x deletes the character that the cursor is on and moves the cursor to the right; and X deletes the character that the cursor is on and moves the cursor to the left.

The d command is a more powerful way to delete. d can be used with many different things after it. dd will delete the entire line. d$ will delete the rest of the current line. de will delete from where the cursor is up until the end of the word.

Replacing <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/d-quT7u3f_o" width="697.6"></iframe>

Lower case r can replace one letter while upper case R can replace one letter with many.

There are three c commands that I regularly use for replacement: ce , which deletes up until the end of the word that the cursor is currently on, then allows you to insert immediately; c$ , which deletes from where the cursor is up until the end of the line, then allows you to insert immediately; and cc , which deletes the whole line that the cursor is on and allows you to insert immediately at the beginning of the line.

Customizing your vim editor with the .vimrc file <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/VhAiVux6GBg?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Ever wondered how’ve we get our vim editor to work in the way we have it versus the default editor? vim has a file where you can setup it’s defaults such as auto parentheses, auto-indent, and much more. By watching our video above, you can easily create new defaults for your vim editor that can cut time spent formating your text to spend more on coding.

Learning The Terminal

One of the best features of Unix operating systems is the powerful terminal they provide.

The ls command <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/xSSahh5HbUY?rel=0&amp;vq=hd1080" width="697.6"></iframe>

The ls command is one of the most used terminal commands.

The basic ls command, when run, displays the contents within the current working directory. Passing in a directory name as an argument will display the contents of that directory. It is also possible to pass in a path for a directory to display any directory, regardless of the directory the user is currently in.

If the -a flag is passed in with ls, all items in the current working directory prepended with a . are also displayed, along with the rest of the items.

Passing in the -l flag prints information for each item in the directory in a series of columns on a single line. The first column displays the read, write, and executable permissions for the main user, the group the current user is in, and any user in that order. The next column shows the owner of the item and the next column shows the group owner. The fourth column displays the size, in bytes, of the item. The fifth column displays the moment the item was created, and the last column displays the name of the item.

If the -R flag is passed in, the command will display the contents of the current directory, and then recursively enter every directory within the current directory and display the contents of that directory, then keep going into every directory until there are no more directories in the current directory it is in.

All these options are combinable for different uses. For example, I could use the -l and -a flags to display the information for the items prepended with a . , or use -R and -l together.

The cd and mv commands <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/1s5TiFbETh4?rel=0&amp;vq=hd1080" width="697.6"></iframe>

The cd and mv commands are crucial commands in order to actually use the terminal. Without cd, I would forever be stuck in their home directory. The mv command is necessary for moving files from one section of the hard drive. The cd command by itself will change the current working directory to the home directory. If passed a directory name that is within the current working directory, the current working directory will be changed to the name of the passed in directory. cd will also take a path as an argument. When a path is passed in, the current working directory will be changed to the directory specified by the path. When cd is passed with .., the directory will go backwards, the directory that the current directory is in.

The mv command will move an item within a certain directory to the directory passed in.

If the destination argument is not a path, the command will look for the destination in the current working directory. The destination argument can be a path, so I can move the item to any directory in the hard drive.

Recording terminal sessions via scripts <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/ZnIrku27C94?rel=0&amp;vq=hd1080" width="697.6"></iframe>

With the script command you can record the commands you run in your terminal into a file. By just typing script file_name_here, you can start a script. Also, you don’t need to worry about making a file beforehand, because when you specify the filename, it will make once for you in that name. Then when you’re done, type exit and your terminal will say your script session has ended and re-state the filename in which it recorded all your commands in.

How To SSH (into well server) <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/Letf4txWPic?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Computer Science students have the ability to log into the school’s server using the ssh command. The way to do access the terminal is to type into the command terminal the following text:

ssh your_NetId@bell.cs.ucr.edu

If it is your first time entering the terminal, you will be asked to trust the encryption that the server uses, then prompted to enter the password associated with your NetID. Once doing all those steps, you will be brought to your home directory on the server. To exit the server, type exit into the command prompt and press enter.

A useful command that moves files to and from the remote server onto your home computer is the scp command. To put items from your home computer to the school’s server, type into the command prompt:

scp filename/absolute_path your_NetID@bell.cs.ucr.edu:absolute_path

To move items from the remote server onto your home computer, type into the command prompt:

scp your_NetID@bell.cs.ucr.edu:absolute_path absolute_path Spectacle App: Using the terminal and vim in one screen <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/j1fnYZp4foI?rel=0&amp;vq=hd1080" width="697.6"></iframe>

One of the first things I noticed about vim that I initially disliked was that it took over the terminal when I used it. Users with Windows 7 & above automatically have this ability by dragging your screen to the left or right border of your screen. Unfortunately, OS X users don’t have this built in ability. To get around this, OS X users can install the Spectacle App which will enable you to organize multiple windows on your screen with a touch of a buttom. To get around this issue, I started using two terminals instead of just one while I was programming. I would run vim using the first terminal and would run the executable in the second. It was as simple as using :w to save on vim instead of using :wq to save and quit. I could now test my code without ever having to close vim.

perror <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/GsoVzP3sRsA?rel=0&amp;vq=hd1080" width="697.6"></iframe>

When programming for unix based operating systems (which is a primary component of CS100), system calls are a prominent component for code. The perror function captures the error value (if returned) from the system call and prints to stdout an error message based on the system call and the type of error. It takes in one c-string argument, which is a message the user can pass in.

Categories: Offsite Blogs

Mike Izbicki: Getting started with GitHub, vim, and bash

Planet Haskell - Sat, 09/06/2014 - 6:00pm
Getting started with GitHub, vim, and bash posted on 2014-09-07 by Rashid Goshtasbi and Kyler Rynear

Learning to use git, vim, and bash was hard for us. These tools are so different than the tools we used when we first learned to program. And they’re confusing! But our professor made us use them… and eventually… after we learned the tools… we discovered that we really like them! So we’ve put together a simple video guide to help you learn and enjoy these tools too. We did this as part of the CS100 open source software development class at UC Riverside.

Click here to watch the full playlist on YouTube.

Getting Started with GitHub <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/bap-NSjgPFg?rel=0&amp;vq=hd1080" width="697.6"></iframe>

This video shows you step by step how to create an account on GitHub. Then we see how to create our first repository called test, and transfer it from GitHub onto our local machine using the git clone command.

Creating a file, pushing to GitHub, and pulling from GitHub <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/UrLkCZaXg9o?rel=0&amp;vq=hd1080" width="697.6"></iframe>

How do we create files and upload them to GitHub? The touch <filename> command will create an empty file for you. The vim <filename> command will open a file in an advanced text editor that we talk about farther down the page. The git push command sends these files from your local machine up to GitHub, and the git pull command downloads files from GitHub and saves them to your local computer.

Branches <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/E8-hUsR7IXA?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Branches let you work on files without messing up your original code. When you finish your changes, you can merge them into the master branch. This is the best part of version control.

Tags <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/WKG1u4Y_f3s?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Most programs have different versions, for example: 1.0, 1.1, 1.2, 2.1 and 2.2.1. The git tag command let’s you create these versions. They’re just like a checkpoint in a Mario game!

Forking & Pull Requests <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/tTnL84EvJTM?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Let’s say you want to contribute to an open source project, but you don’t have permission. In order to contribute to someone else’s repository, you must first “fork” it to create a repo that you do have push permission on. Then you issue a pull request through the GitHub website. This tells the owner of the original repo that you’ve made some changes they can incorporate.

The README.md file <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/4UTSEKzsSvM?rel=0&amp;vq=hd1080" width="697.6"></iframe>

README.md files are how you document your projects. The README.md should explain your program, give installation instructions, and list known bugs. Basically, it explains to someone else who has absolutely no idea what your program does or how to code, but it enables the user to understand the concepts and basic directions to execute your program. The .md extension at the end of the filename indicates that the file uses markdown formatting. This is a simple way to create nice looking documentation.

Learning vim

vim is an advanced text editor for Unix operating systems. It’s powerful, but all the commands are intimidating for first time users. Even though it’s hard to get used to at first, these videos will help you learn some of the basic commands and get comfortable with vim.

Getting Started <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/szTtE60fIt8?rel=0&amp;vq=hd1080" width="697.6"></iframe>

It was difficult at first trying to transverse my code while using vim. I was so used to being able to use my mouse and simply click where I wanted to go. There are many ways to maneuver inside of vim. Some may just use the h,j,k,l, up, down, left, right arrow keys, or the w, e, b keys to move. You can also press gg to go to the top of the code, G to go to the bottom of it, and (any number)G to go to the line number typed before the capital G.)

Cutting, copying, and pasting took a while to get used to when using vim. Sometimes there was something I wanted in my code that was in the instructions for the assignment. In order to paste I would use the p command, but I could not paste things from outside of vim into it. If I had something copied outside of vim, then to paste it into vim I would right click and just click paste. This would paste it wherever the cursor currently is. If you right click to copy, then it will not affect what is copied by using the commands y to copy or the commands d or x to cut. If those commands are used, the just clicking p will paste them. There are other ways to store more than one thing while copying or cutting, but these two ways were the most helpful as I learned how to use vim.

Another personal favorite features of vim, are the shift-a (takes you to the end of the line and into insert mode) and the shift-i (takes you to the beginning of the line and into insert mode) command. You can also press a to append after the cursor position, as well as i to insert before the current cursor position

vim also allows you to use the v or shift-v keys to highlight certain text or lines of code. You can then use other vim commands such as the copy, paste and delete keys to perform your needed actions.

Indentation <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/uuztdE_gixs?rel=0&amp;vq=hd1080" width="697.6"></iframe>

At first it felt very time consuming to indent multiple lines. I felt this way until I found about the V command. V lets users highlight a line and pressing up or down can highlight as many lines as they desire. All that was left to do was to type > after everything I wanted to indent was highlighted and it all would indented once to the right. Typing < would instead indent it to the left if I ever wanted to do that.

Deletion <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/x0BMbS2kWYc" width="697.6"></iframe>

There are two commands for deleting single character. x deletes the character that the cursor is on and moves the cursor to the right; and X deletes the character that the cursor is on and moves the cursor to the left.

The d command is a more powerful way to delete. d can be used with many different things after it. dd will delete the entire line. d$ will delete the rest of the current line. de will delete from where the cursor is up until the end of the word.

Replacing <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/d-quT7u3f_o" width="697.6"></iframe>

Lower case r can replace one letter while upper case R can replace one letter with many.

There are three c commands that I regularly use for replacement: ce , which deletes up until the end of the word that the cursor is currently on, then allows you to insert immediately; c$ , which deletes from where the cursor is up until the end of the line, then allows you to insert immediately; and cc , which deletes the whole line that the cursor is on and allows you to insert immediately at the beginning of the line.

Customizing your vim editor with the .vimrc file <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/VhAiVux6GBg?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Ever wondered how’ve we get our vim editor to work in the way we have it versus the default editor? vim has a file where you can setup it’s defaults such as auto parentheses, auto-indent, and much more. By watching our video above, you can easily create new defaults for your vim editor that can cut time spent formating your text to spend more on coding.

Learning The Terminal

One of the best features of Unix operating systems is the powerful terminal they provide.

The ls command <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/xSSahh5HbUY?rel=0&amp;vq=hd1080" width="697.6"></iframe>

The ls command is one of the most used terminal commands.

The basic ls command, when run, displays the contents within the current working directory. Passing in a directory name as an argument will display the contents of that directory. It is also possible to pass in a path for a directory to display any directory, regardless of the directory the user is currently in.

If the -a flag is passed in with ls, all items in the current working directory prepended with a . are also displayed, along with the rest of the items.

Passing in the -l flag prints information for each item in the directory in a series of columns on a single line. The first column displays the read, write, and executable permissions for the main user, the group the current user is in, and any user in that order. The next column shows the owner of the item and the next column shows the group owner. The fourth column displays the size, in bytes, of the item. The fifth column displays the moment the item was created, and the last column displays the name of the item.

If the -R flag is passed in, the command will display the contents of the current directory, and then recursively enter every directory within the current directory and display the contents of that directory, then keep going into every directory until there are no more directories in the current directory it is in.

All these options are combinable for different uses. For example, I could use the -l and -a flags to display the information for the items prepended with a . , or use -R and -l together.

The cd and mv commands <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/1s5TiFbETh4?rel=0&amp;vq=hd1080" width="697.6"></iframe>

The cd and mv commands are crucial commands in order to actually use the terminal. Without cd, I would forever be stuck in their home directory. The mv command is necessary for moving files from one section of the hard drive. The cd command by itself will change the current working directory to the home directory. If passed a directory name that is within the current working directory, the current working directory will be changed to the name of the passed in directory. cd will also take a path as an argument. When a path is passed in, the current working directory will be changed to the directory specified by the path. When cd is passed with .., the directory will go backwards, the directory that the current directory is in.

The mv command will move an item within a certain directory to the directory passed in.

If the destination argument is not a path, the command will look for the destination in the current working directory. The destination argument can be a path, so I can move the item to any directory in the hard drive.

Recording terminal sessions via scripts <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/ZnIrku27C94?rel=0&amp;vq=hd1080" width="697.6"></iframe>

With the script command you can record the commands you run in your terminal into a file. By just typing script file_name_here, you can start a script. Also, you don’t need to worry about making a file beforehand, because when you specify the filename, it will make once for you in that name. Then when you’re done, type exit and your terminal will say your script session has ended and re-state the filename in which it recorded all your commands in.

How To SSH (into well server) <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/Letf4txWPic?rel=0&amp;vq=hd1080" width="697.6"></iframe>

Computer Science students have the ability to log into the school’s server using the ssh command. The way to do access the terminal is to type into the command terminal the following text:

ssh your_NetId@bell.cs.ucr.edu

If it is your first time entering the terminal, you will be asked to trust the encryption that the server uses, then prompted to enter the password associated with your NetID. Once doing all those steps, you will be brought to your home directory on the server. To exit the server, type exit into the command prompt and press enter.

A useful command that moves files to and from the remote server onto your home computer is the scp command. To put items from your home computer to the school’s server, type into the command prompt:

scp filename/absolute_path your_NetID@bell.cs.ucr.edu:absolute_path

To move items from the remote server onto your home computer, type into the command prompt:

scp your_NetID@bell.cs.ucr.edu:absolute_path absolute_path Spectacle App: Using the terminal and vim in one screen <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/j1fnYZp4foI?rel=0&amp;vq=hd1080" width="697.6"></iframe>

One of the first things I noticed about vim that I initially disliked was that it took over the terminal when I used it. Users with Windows 7 & above automatically have this ability by dragging your screen to the left or right border of your screen. Unfortunately, OS X users don’t have this built in ability. To get around this, OS X users can install the Spectacle App which will enable you to organize multiple windows on your screen with a touch of a buttom. To get around this issue, I started using two terminals instead of just one while I was programming. I would run vim using the first terminal and would run the executable in the second. It was as simple as using :w to save on vim instead of using :wq to save and quit. I could now test my code without ever having to close vim.

perror <iframe allowfullscreen="allowfullscreen" frameborder="0" height="419.65" src="https://www.youtube.com/embed/GsoVzP3sRsA?rel=0&amp;vq=hd1080" width="697.6"></iframe>

When programming for unix based operating systems (which is a primary component of CS100), system calls are a prominent component for code. The perror function captures the error value (if returned) from the system call and prints to stdout an error message based on the system call and the type of error. It takes in one c-string argument, which is a message the user can pass in.

Categories: Offsite Blogs