Skip to content

MondayMorningHaskell/HaskellData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HaskellData

This is the companion Github repository for the Haskell Data Series on Monday Morning Haskell! This series compares the basic construction of data types in Haskell, Java, and Python, so it has code samples in all three languares:

  1. Haskell Code
  2. Java Code
  3. Python Code

Running the Code

The code samples are fairly simple and easy to run, assuming you have the basic programs installed for each language.

Running Haskell Code

Start by building the repository and loading up GHCI:

>> stack build
>> stack ghci

Then within GHCI, you can explore any of the individual modules. Since there are some overlapping types between the modules, you should first use the command :load, and then you can load a single module. You are then free to .

> :load
> import Basic
> firstPerson
SimplePerson "Michael" "Smith" "msmith@gmail.com" 32 "Lawyer"

If you change any of the elements in the module, or add your own, you can also reload with :r

> :r
> firstPerson
SimplePerson "Mike" "Smith" "msmith@gmail.com" 32 "Lawyer"

Running Java Code

The Java code modules are all written such that you can run each one's main function as an executable. So given the source code:

public class Basic {
  public static void main(String[] args) {
    Person p = new Person("Jane", "Doe", "jane.doe@gmail.com", 35, "Project Manager");
    System.out.println(p.getLastName());
  }
}

You can see the output like so:

>> cd java
>> java Basic.java
Doe

Running Python Code

The Python code works in much the same way as the Java code. Note though, that it uses Python3. Some of the code is incompatible with Python2.

>> cd python
>> python3 Basic.py

You can modify the "if name = main" portion and provide new definitions if you want above it:

if __name__ == "__main__":
  p = Person("Jane", "Doe", "jane.doe@gmail.com", 35, "Project Manager")
  print(p.occupation)

Code Samples by Article

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published