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
| class RorMethod1: | |
| """ | |
| RorMethod1,2 classes act as functools.partial with method-like ror application. | |
| """ | |
| def __init__(self, function): | |
| """ function may be print or sorted """ | |
| self.function = function | |
| def __ror__(self, value): | |
| return self.function(value) | |
| def __call__(self, *args): |
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
| class Show' a where show' :: a -> String | |
| instance Show' Integer where show' = show | |
| main = do | |
| putStrLn $ show 42 -- OK | |
| putStrLn $ show' 42 -- Error! Why? |
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 Control.Applicative | |
| newtype Noop a = Noop { run :: () } | |
| instance Functor Noop where | |
| fmap = const $ const $ Noop () | |
| instance Applicative Noop where | |
| pure = const $ Noop () | |
| (<*>) = const $ const $ Noop () |
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
| #include <iostream> | |
| using namespace std; | |
| template <typename A> | |
| A antiId(A x) { return x; } | |
| template <> | |
| int antiId<int>(int) { return 42; } | |
| int main() { |
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
| {-# OPTIONS -Wall -Werror #-} | |
| antiId :: a -> a | |
| antiId x = x | |
| {-# NOINLINE antiId #-} | |
| {-# RULES | |
| "antiId@Int" forall (x :: Int). antiId x = 42 | |
| #-} | |
| data A = A |
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
| #include <iostream> | |
| #include <memory> | |
| #include <vector> | |
| using namespace std; | |
| template <typename a> | |
| struct Nested { | |
| virtual | |
| int length() const = 0; | |
| }; |
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
| {-# LANGUAGE BangPatterns, ScopedTypeVariables #-} | |
| import Control.Applicative ( liftA2 ) | |
| import Control.DeepSeq ( deepseq ) | |
| import Control.Monad ( forM_ ) | |
| import Control.Monad.ST.Strict ( runST ) | |
| import Criterion ( bench, bgroup, nf, runAndAnalyse ) | |
| import Criterion.Config ( Config(..), defaultConfig, ljust ) | |
| import Criterion.Environment ( measureEnvironment ) | |
| import Criterion.Monad ( withConfig ) |
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
| $ which ghc | |
| /usr/bin/ghc | |
| $ file /usr/bin/ghc | |
| /usr/bin/ghc: symbolic link to `../lib/ghc/bin/ghc' | |
| $ file /usr/lib/ghc/bin/ghc | |
| /usr/lib/ghc/bin/ghc: symbolic link to `ghc-7.6.3' | |
| $ file /usr/lib/ghc/bin/ghc-7.6.3 |
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
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| int main() { | |
| auto add = [](auto x){ | |
| return [=](auto y){ | |
| return x + y; | |
| }; | |
| }; |
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
| #include <iostream> | |
| using namespace std; | |
| #include <experimental/optional> | |
| using namespace std::experimental; | |
| template <class value_type, class... argument_types> | |
| struct Closure { | |
| using arguments_type = tuple<argument_types...>; | |
| using function_type = function<Closure(arguments_type)>; |
OlderNewer