[1,2,3,4,5]
2026-09-04
bohanjiang@brandeis.eduGHCup in https://www.haskell.org/ghcup/curlGHC: Haskell compilercabal-install: tool for managing Haskell softwareStack: program for developing Haskell projectslanguage-server: Enable IDE featuresLaunch the environment by
Simple arithmetic
Print a string
Define a function
Haskell is a programming language having following features:
We have below expressions
:: is pronounced as “has type”
= is pronounced as “is defined to be”
Variable names must be in camelCase
+, -, /, *, ^, mod etc.&&, ||, ==, /=, >, <, ... etc.String):t on an expression to print out its typeInt: Machine-sized integers (\(\pm 2^{64}\) if your machine is 64-bit)Float: single precision floatChar: unicode charactersBool: boolen type[Char]?:t check a built-in function heada is a type variable, and it can be any type (generic type in other imperative languages)==?Eq typeclassEq is the typeclass, which provides an interface for testing for equality
def __eq__(self, other)=> is called class constraint, which constrain the type variable a must be a member of the Eq classEqOrd: covers all the standard comparing functions (all types so far except for functions)Show: members know how to represent strings (all types so far except for functions)Read: knows how to interpret its textual representationEnum: members can be sequentially ordered (i.e. enumerated)Bounded: members have the lowest and the largest boundsNum: members are numericIntegral: members are whole numbersFloating: members are floating point numbers sayNum which takes an Int and yields Stringsumtorial which computes the sum of the integers from 1 to nrelu that implements ReLU function where \(f(x) = max(0, x)\)Brandeis Fall 2026 CS135 Recitation