Midwest.io 2014 - Demystifying Haskell - Andrew Rademacher

  Рет қаралды 22,369

Midwest.io

Midwest.io

Күн бұрын

Пікірлер: 36
@muckelkassel
@muckelkassel 10 жыл бұрын
This is a neat primer for people interested in why haskell is useful.
@chilidili
@chilidili 10 жыл бұрын
dang what a killer presentation
@awilliamwest
@awilliamwest 10 жыл бұрын
fibs=1:1:zipWith(+)fibs(tail fibs) ... yeah, I like demonstrating that, too. But I think explaining the Either monad and how that can help reduce complexity could help, too. Many think that since Haskell is "mathematical", that means it's good for pure computation. No! (not that it's bad...but that isn't the point of Haskell.) It's about managing complexity. Mathematical abstractions can be extended to control flow, as they are in FRP, and abstracting-away the loops and ifs that would normally appear in most languages yields incredibly composable software. Coding in that style is an unnatural discipline at first, but you get used to it in time.
@kyp0717
@kyp0717 9 жыл бұрын
Great speaker!!!!
@AnimeshSharma1977
@AnimeshSharma1977 10 жыл бұрын
Haskell brings out this sense of purity to me which no other language does, just that PERL is so good with string processing and Matlab with numerical computation that i prefer these for my day job... probably it will change after this presentation :)
@HaskellMadrid
@HaskellMadrid 8 жыл бұрын
Great speaker and excellent topic... HaskellMAD
@miladzahedi1048
@miladzahedi1048 7 жыл бұрын
Awesome I particularly liked the part about memoization
@Bunnokazooie
@Bunnokazooie 5 жыл бұрын
I didn't know chris pratt knew haskell
@cajal6
@cajal6 10 жыл бұрын
This was a good intro to Haskell, but there were several advanced functional programming topics (like pattern matching, for instance) that he glossed over. Would have been better with a bit more time to delve into those topics as well.
@codeshot1795
@codeshot1795 5 жыл бұрын
-- don't bother with the tuple, add directly fibs = 1 : 1 : (zipWith (+) fibs (tail fibs)) -- factor out application to the argument 'fibs' fibs = 1 : 1 : (zipWith (+) tail $ fibs) -- use list append instead of cons because ... you'll see why in a moment fibs = [1,1] ++ (zipWith (+) tail $ fibs) -- use an operator section fibs = ([1,1] ++) (zipWith (+) tail $ fibs) -- use composition to bring the self-reference of fibs to the top of the syntax tree fibs = ([1,1]++) . (zipWith (+) tail) $ fibs -- factor out the self reference so the name of the list isn't needed at all -- note this can be read almost directly -- self-referentially produce the list starting 1,1 followed by what you get if you add -- each from this list to its follower which is in the corresponding point of the list's tail fibs = fix $ ([1, 1] ++) . (zipWith (+) tail) This is a valuable technique because you can unit test a sequence and therefore avoid having to debug: import Data.Function initial = ([1, 1] ++) extension = zipWith (+) tail fibs_step = initial . extension fibs = fix fibs_step main = do let write :: (Show t) => t -> IO () write = putStrLn . show -- ==.. compares up to two elements of a list (==..) = (==) `on` take 2 infixr 3 ==.. write $ initial [] == [1,1] write $ initial [3] == [1,1,3] write $ initial [3,4] == [1,1,3,4] write $ extension [0,0] == [0] write $ extension [0,1] == [1] write $ extension [1,0] == [1] write $ extension [1,1] == [2] write $ extension [2,5] == [7] write $ extension [2,5,6,4] == [7,11,10] -- the first 5 cases promise that the 6th is always what we get -- but they're not a proof, because the 3rd only checks the first two elements, and maybe -- there are more, but maybe we can't check... although if we're smart we can change -- take 2 to take 3 and watch what happens to get a clue so we can still avoid debugging -- but I know the fixed point *always* starts [1,1] write $ fibs_step [] == initial [] write $ fibs_step [undefined] == initial [] write $ fibs_step [undefined, undefined] ==.. initial [] write $ fibs_step [undefined, undefined, undefined] ==.. initial [] write $ fibs_step undefined ==.. initial [] write $ fibs_step (initial []) == [1,1,2] write $ fibs_step [1,1,2] == [1,1,2,3]
@osquigene
@osquigene 5 жыл бұрын
I'm surprise how close this looks to python. One thing I had to search for is why do you use `1 : 1 : [2, 3, 5]` if `++` is the concatenation operator. In case someone is wondering the same (stackoverflow.com/questions/5649435/syntax-for-list-construction-concatenation), the types of these two functions are different: (:) :: a -> [a] -> [a] (++) :: [a] -> [a] -> [a] So I guess we could have written `[1] ++ [1] ++ [2, 3, 5]` even though that would make no sense since `:` exists.
@seppeljordan
@seppeljordan 9 жыл бұрын
Tuples are not small lists. In Haskell you can not iterate over the members of a tuple (with standard iteration procedures).
@0LoneTech
@0LoneTech 6 жыл бұрын
9:55 - no, you don't have random access in tuples (not as in the RA in RAM, anyway), because they're heterogeneous an index operation wouldn't have a known type. They can be destructured easily though; none of the entries are more costly to access, unlike a list.
@skepticmoderate5790
@skepticmoderate5790 4 жыл бұрын
Random access refers to O(1) look up of any element. Whereas accessing an element in a list is O(n) in the worst case.
@edvansousa1270
@edvansousa1270 5 жыл бұрын
thanks. Great presentation.
@wangox
@wangox 10 жыл бұрын
Really Intresting presentation. :)
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Embodiment of Boss.
@tincho15neem
@tincho15neem 3 жыл бұрын
why do you put comments as //?
@GertCuykens
@GertCuykens 10 жыл бұрын
Data type name and a Class name looks identical in haskell code and it was so confusing for me. If you could make them a different color or something that would help me allot. Also the language extensions made it possible to write the same thing in so many ways, it took me a long time to understand a program. So for now I need something like golang not because it is better but because I can understand other peoples code faster.
@GertCuykens
@GertCuykens 9 жыл бұрын
FichDichInDemArsch​ Sorry I can't explain it better, I don't think it was because of OOP but when you have a type that consist of other types then the syntax got confusing for me.
@MasthaX
@MasthaX 4 жыл бұрын
Didn't know Seth McFarlane had a brother who'd code.
@johannbauer2863
@johannbauer2863 5 жыл бұрын
actually tuple has a limit of 66 afaik
@MorganEarlJones
@MorganEarlJones 8 жыл бұрын
I might have an oversimplified interpretation of what I've seen here, but wouldn't [value] ++ list be the same thing as value : list ? It seems odd that an entire operator would be given to save programmers the task of entering a couple of square brackets and plus signs.
@sshuck
@sshuck 8 жыл бұрын
Correct. 1) In general, one of the odd things about Haskell IMO is how you're given functions and operators that are trivial modifications of other functions and operators. Like, mapM_ is just void . mapM, forM_ is just flip mapM_, >>> is just flip (.), concat is just join, map is just fmap, etc. 2) However, (:) and (++) both existing isn't that weird. (:) is a data constructor instantiating a singly linked list node, where the first operand is the value and the second is the next node. (++) is concatenation of two lists. This is like other languages where you *would* still find "new Node()" and "List.concat()" as separate things.
@skepticmoderate5790
@skepticmoderate5790 4 жыл бұрын
Haskell is a truly strongly-typed language. The type of the cons (:) operator is (a -> [a] -> [a] (where a is ANY type)), whereas the type of the concatenation (++) operator is ([a] -> [a] -> [a]). As you can see, these types are fundamentally incompatible. That is why they have different operators.
@takumfnongivenames1402
@takumfnongivenames1402 10 жыл бұрын
Not to get overly critical, but giving this example as efficiency comparison is not really fair. It shows one strong side of Haskell that could be easily mitigated with using 3 variables as Fibonacci terms along with one variable as index number. a = 1, b = 1, c = 0; while(index
@crcaccounts
@crcaccounts 9 жыл бұрын
Your algorithm lacks the features automatically available in haskell though. At the end he showed the ability to sum the list, and haskell's auto memoization of previously computed values made it easy to grab the next value in the series. You can have it both ways in haskell, the full list, or just the last value, without having to code the algorithm with a specific purpose in mind. The haskell language provides this for free, C doesn't, so this is not a valid criticism.
@takumfnongivenames1402
@takumfnongivenames1402 9 жыл бұрын
crcaccounts But there is a way to solve this problem without the need of such features. Just selection of best implementation strategy for problem in hand. This is what I wanted to point out, nothing more. You have choice in a lot languages, it does not mean they will perform equally with the exact same algorithm. I am not pro or against any of these languages, don't even see the merit in talking about comparing them in any way considering how it is the matter of personal taste. If it makes anyone feel better: I like Haskell. Just like I like C or Scheme. I simply don't compare them in general. To me 'C vs Haskell' would be pointless in most cases, seeing how one is intended as minimalistic imperative language and another as general purpose functional language. From my 'pen and paper mathematician first, programmer second' perspective it is about as subjective and context sensitive as you can get. If anything, lets agree to disagree and move on. Last thing I want (or anybody needs to see) is a highly subjective discussion of needs, features and why X is better then Y.
@samgoodwin89
@samgoodwin89 9 жыл бұрын
Takumf Nongivenames I'm not 100% on the behaviour of the JVM but he ran it with -Xms14g which sets the minimum heap size to 14 gigs. So ofcourse it's going to use a bunch of memory.
@giganetom
@giganetom 6 жыл бұрын
"...or any of that nonsense" XD
@skepticmoderate5790
@skepticmoderate5790 4 жыл бұрын
This video is very dishonest. The computation at the end is only trying to find the 475000th fib. He should be using an iterative algorithm rather than storing all 475000 intermediate values. That's essentially what Haskell does under the hood. Thus some imperative Python would be as follows: def fib(n): x, y = 1, 1 for _ in range(1, n): x, y = y, x + y return y Yes, you'll have additional complexity due to big int libraries for languages other than python. But this code is approximately O(1) space in any imperative language, just as the Haskell code is.
@autumn_leaves0
@autumn_leaves0 9 жыл бұрын
we could all learn 'brainfuck' if we wanted to write unreadable code...
@malcolmforde4969
@malcolmforde4969 9 жыл бұрын
Benjamin Kararic Haskell is pretty readable if you understand the syntax.
@autumn_leaves0
@autumn_leaves0 9 жыл бұрын
never gave it a chance rly :p, just got my mind set on something els. if its true that its better for multithreading in the future with more cores i will have to adapt. still now im sticking with the beatiful java :D
@malcolmforde4969
@malcolmforde4969 9 жыл бұрын
Benjamin Kararic Yeah, I understand. Haskell is a very different language from most.
In Haskell, less is more
57:51
London Haskell
Рет қаралды 22 М.
"Writing a game in Haskell" by Elise Huard
29:37
Strange Loop Conference
Рет қаралды 47 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 17 МЛН
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 44 МЛН
Haunted House 😰😨 LeoNata family #shorts
00:37
LeoNata Family
Рет қаралды 15 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 103 МЛН
Functional Programming & Haskell - Computerphile
9:19
Computerphile
Рет қаралды 671 М.
Production Haskell - Reid Draper
1:06:34
Chicago Haskell
Рет қаралды 19 М.
Haskell is Not For Production and Other Tales
38:19
Linux.conf.au 2016 -- Geelong, Australia
Рет қаралды 100 М.
03-06 Function Composition (Introduction to Haskell)
45:15
Well-Typed
Рет қаралды 308
Introducing 0DE5
39:38
Kay Lack
Рет қаралды 107 М.
Haskell Amuse-Bouche
57:13
Google TechTalks
Рет қаралды 77 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 17 МЛН