- Exceptions
- Delimited continuations, because continuations are cool.
- Macros (maybe)
- Attribute lookup – lenses?
- Keyword parameters
- [GHC implicit parameters][] are interesting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | Birthday paradox calculator | |
| import Control.Monad | |
| import Data.Ratio | |
| import System.Environment | |
| import Text.Printf | |
| birthday :: Fractional a => Integer -> Integer -> a | |
| birthday days n = realToFrac $ 1 - inverse | |
| where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript: | |
| var frm = window.frames[2]; | |
| function next(f) { | |
| setTimeout(f, 100); | |
| } | |
| function doClick(elem) { | |
| var evt = document.createEvent("MouseEvents"); | |
| evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
| elem.dispatchEvent(evt); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import qualified Control.Exception.Lifted as Lifted | |
| import Control.Monad.Trans.Control | |
| -- | Set an option, run an action, then restore the option to its | |
| -- previous value. | |
| -- | |
| -- @saveRestore get set value action@ is roughly equivalent to: | |
| -- | |
| -- > do orig <- get | |
| -- > set value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | Lock-step folding. | |
| -- | |
| -- This module presents an elegant way of executing multiple left folds | |
| -- on one list using constant memory. For example, the mean can be | |
| -- expressed as: | |
| -- | |
| -- @ | |
| -- average = foldLeft $ (/) <$> sumF <*> lengthF | |
| -- @ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | <http://ncss.edu.au/challenge/ncss_challenge_2012.pdf> | |
| class Semigroup a where | |
| (<>) :: a -> a -> a | |
| data Result = Team String | Draw Int | |
| resultLength :: Result -> Int | |
| resultLength (Team name) = length name | |
| resultLength (Draw lgth) = lgth |
NewerOlder