Skip to content

Instantly share code, notes, and snippets.

View auxiliaire's full-sized avatar

Viktor Daróczi auxiliaire

View GitHub Profile
@nikoheikkila
nikoheikkila / repeat.hs
Last active June 14, 2021 15:58
Haskell: Module that repeats any IO action n times
module Repeater where
-- General usable module that repeats any IO action n times.
-- by Niko Heikkilä
repeatIOAction :: Int -> IO () -> IO () -- Inputs: integer and IO. Outputs: IO
repeatIOAction 0 _ = return () -- exit recursive loop here
repeatIOAction n action = do
action -- action to perform
repeatIOAction (n-1) action -- decrement n to make it recursive