HNHacker News
TopNewBestAskShowJobs

wowthisanacct

1 karma · joined October 20, 2019

submissionscomments
wowthisanacct··on Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
https://news.ycombinator.com/item?id=21304512
wowthisanacct··on Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

  data Numberable = Numberable {
    first  :: IO ()
   ,second :: IO ()
   ,third  :: IO ()
  }

  parent = Numberable {first = return (), second = return (), third = return ()}

  child = parent { third = print 'third' }

And if you wanted to DI into a function:

  data Env = { numberable :: Numberable }

  doStuff :: (MonadIO m, MonadReader Env m) => Int -> Int -> m ()
  doStuff num1 num2 = do
    myNumberable <- reader numberable
    print (show num1)
    print (show num2)
    liftIO (third myNumberable)