Artwork

Content provided by Jesse Tomchak. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jesse Tomchak or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

65: Haskell I/O

21:28
 
Share
 

Archived series ("Inactive feed" status)

When? This feed was archived on October 04, 2020 13:08 (3+ y ago). Last successful fetch was on January 04, 2020 14:08 (4+ y ago)

Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.

What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.

Manage episode 224854710 series 1531971
Content provided by Jesse Tomchak. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jesse Tomchak or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

It as dawned on me as I have tried to find a better way to number, categorize this episodes, that each unit has about a dozen lessons. So Unit 4, that we’ll cover now are lessons 20-23.

IO in Haskell
  • avoiding state is the one of the key tenants of Haskell.
  • So how does Haskell rectify that tenant with the need to acutally makes changes to the outside world? like files, network requests, or other types of interaction
  • You should know this by now. Types!!
Special parameterized type
  • name? you guessed it, IO
  • Any value in IO context MUST stay in this context.
  • This prevents it from clouding up or haskell environment of purity.

    • For refresher, when I say purtity, what I mean is that it upholds referential transparency and doesn’t change state. Like a pure function.
    • IO makes it impossible to use values that are from IO in pure functions where, that function is not expecting to get polluted values that can’t really be trusted.
PSA Why writing every example is so important.
  • Even as I write out the samples I had to search for the following

    • loading a file into ghci
    • run and eval a .hs file
    • Data constructor is not in scope?

      • oh i was missing a second colon in the main type definition
    • Main was uppercased.
    • build random, not included in the main lib since 7.2

      • had to stack install it
      • then built it, tried to stack exec it, but I’d built it with ghc, so I had an executable, once i realized that i could just ./ call it. 🙄
  • This process is the learning. I know how to do this in JS. bc I’ve done it a thousand times! This is your chance to put down the muscle memory to a new language.
  • Don’t know it, can’t quite remember that command? Try something ? anything. use -h so see if you can figure it out.
  • but DON’T DWELL on it. This can be toxic. You don’t want to be frustrated, you want learn it and move on. Keep that in mind.
We’ve seen new things
  • The IO () type. Which appears to be an innvoced function! NOPE

    • it’s return is an empty tuple! more in a bit
  • The do keywork
  • putStrLn does that return a value ?
  • And my favorite curveball, A backwords arrow

    • getLine returns not a String, but a String IO
IO
  • parameterized type. remember like Maybe?
  • Like Maybe, IO describes a context for their parameters rather than a container.

    • I’ve thought of Maybe as a container that until unpacked coulbe have a value or be empty. If I can find the drawning that I always think of, I’ll link it. It was a while ago when I got a taste for functional programming, without knowing, through Swift.
  • The context that IO communicated is that came from / originated from an input/output operation, NOT from a pure function
  • The context for IO is a lot broader than for Maybe. Where Maybe is a possible missing value. IO can have an endless list of problems. How to account for all of them? That why this context for these values exists!
  • It’s a way to separate the code that deals with these uncertains, and the code in our Haskell program where we rely on these certians to make particular assumptions with of course help from the compiler.
  • IO actions are not functions. I repeat, not functions. Just a tuple with with Zero elements.
putStrLn
  • returns nothing at all! hence the empty tuple on our IO, the nothing is our return value! 😵
  • the empty tuple is the best way to communicate the nothing/empty return value

    • Not nessary in Maybe because Just () is eq to Nothing
  • bc of this Main isn’t a function, it must return a value. So we refer to it as an IO Action that action being a side effect!

    • other IO Actions might return a value, but not take a init value or doesn’t always return the same value. whatever it might be, it will violate 1 of the 3 rules that that a function must follow in Haskell.
  • putStrLn is an IO Action gottcha!!
  • and since putStrLn is an IO Action for not returning a value, getLine does’t take a value, so it too is an IO Action too. Ah ha!!!
Resources Get Programming With Haskell I/O Tutorial Follow

  continue reading

91 episodes

Artwork

65: Haskell I/O

Javascript to Elm

73 subscribers

published

iconShare
 

Archived series ("Inactive feed" status)

When? This feed was archived on October 04, 2020 13:08 (3+ y ago). Last successful fetch was on January 04, 2020 14:08 (4+ y ago)

Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.

What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.

Manage episode 224854710 series 1531971
Content provided by Jesse Tomchak. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jesse Tomchak or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

It as dawned on me as I have tried to find a better way to number, categorize this episodes, that each unit has about a dozen lessons. So Unit 4, that we’ll cover now are lessons 20-23.

IO in Haskell
  • avoiding state is the one of the key tenants of Haskell.
  • So how does Haskell rectify that tenant with the need to acutally makes changes to the outside world? like files, network requests, or other types of interaction
  • You should know this by now. Types!!
Special parameterized type
  • name? you guessed it, IO
  • Any value in IO context MUST stay in this context.
  • This prevents it from clouding up or haskell environment of purity.

    • For refresher, when I say purtity, what I mean is that it upholds referential transparency and doesn’t change state. Like a pure function.
    • IO makes it impossible to use values that are from IO in pure functions where, that function is not expecting to get polluted values that can’t really be trusted.
PSA Why writing every example is so important.
  • Even as I write out the samples I had to search for the following

    • loading a file into ghci
    • run and eval a .hs file
    • Data constructor is not in scope?

      • oh i was missing a second colon in the main type definition
    • Main was uppercased.
    • build random, not included in the main lib since 7.2

      • had to stack install it
      • then built it, tried to stack exec it, but I’d built it with ghc, so I had an executable, once i realized that i could just ./ call it. 🙄
  • This process is the learning. I know how to do this in JS. bc I’ve done it a thousand times! This is your chance to put down the muscle memory to a new language.
  • Don’t know it, can’t quite remember that command? Try something ? anything. use -h so see if you can figure it out.
  • but DON’T DWELL on it. This can be toxic. You don’t want to be frustrated, you want learn it and move on. Keep that in mind.
We’ve seen new things
  • The IO () type. Which appears to be an innvoced function! NOPE

    • it’s return is an empty tuple! more in a bit
  • The do keywork
  • putStrLn does that return a value ?
  • And my favorite curveball, A backwords arrow

    • getLine returns not a String, but a String IO
IO
  • parameterized type. remember like Maybe?
  • Like Maybe, IO describes a context for their parameters rather than a container.

    • I’ve thought of Maybe as a container that until unpacked coulbe have a value or be empty. If I can find the drawning that I always think of, I’ll link it. It was a while ago when I got a taste for functional programming, without knowing, through Swift.
  • The context that IO communicated is that came from / originated from an input/output operation, NOT from a pure function
  • The context for IO is a lot broader than for Maybe. Where Maybe is a possible missing value. IO can have an endless list of problems. How to account for all of them? That why this context for these values exists!
  • It’s a way to separate the code that deals with these uncertains, and the code in our Haskell program where we rely on these certians to make particular assumptions with of course help from the compiler.
  • IO actions are not functions. I repeat, not functions. Just a tuple with with Zero elements.
putStrLn
  • returns nothing at all! hence the empty tuple on our IO, the nothing is our return value! 😵
  • the empty tuple is the best way to communicate the nothing/empty return value

    • Not nessary in Maybe because Just () is eq to Nothing
  • bc of this Main isn’t a function, it must return a value. So we refer to it as an IO Action that action being a side effect!

    • other IO Actions might return a value, but not take a init value or doesn’t always return the same value. whatever it might be, it will violate 1 of the 3 rules that that a function must follow in Haskell.
  • putStrLn is an IO Action gottcha!!
  • and since putStrLn is an IO Action for not returning a value, getLine does’t take a value, so it too is an IO Action too. Ah ha!!!
Resources Get Programming With Haskell I/O Tutorial Follow

  continue reading

91 episodes

모든 에피소드

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide