Skip to content

Instantly share code, notes, and snippets.

@umairsd
Created October 3, 2015 13:01
Show Gist options
  • Select an option

  • Save umairsd/a1fd12b091dbb5d09e69 to your computer and use it in GitHub Desktop.

Select an option

Save umairsd/a1fd12b091dbb5d09e69 to your computer and use it in GitHub Desktop.
General purpose Haskell functions
-- a function that's equivalent to the standard library's sequence function
myseq ms = foldr k ([[]]) ms
where k m m' = [x:xs | x <- m, xs <- m']
-- another variant of the sequence function, uses return [] instead of [[]]
myseq1 ms = foldr k (return []) ms
where k m m' = [x:xs | x <- m, xs <- m']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment