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
| module Main | |
| ( main | |
| ) where | |
| import Data.Char | |
| import Data.Set (Set) | |
| import qualified Data.Set as S | |
| import Control.Monad.Reader | |
| import Control.Monad.IO.Class |
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
| Noise x >>= f = unsafePerformIO $ do | |
| rand <- (randomIO :: IO Bool) | |
| case rand of | |
| True -> error "fuck" | |
| False -> return $ f x |
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 <stdexcept> | |
| #include "match.hpp" | |
| int main() { | |
| int a, b, c; | |
| zoid::match_tie(a, b, zoid::predicate<int, std::equal_to<int>>{42}, c) = std::make_tuple(1, 2, 42, 3); | |
| std::cout << a << ", " << b << ", " << c << std::endl; | |
| try { |
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
| daknok% valgrind ./a.out ~/Desktop | |
| ==11847== Memcheck, a memory error detector | |
| ==11847== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. | |
| ==11847== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info | |
| ==11847== Command: ./a.out | |
| ==11847== | |
| ==11847== WARNING: Support on MacOS 10.8 is experimental and mostly broken. | |
| ==11847== WARNING: Expect incorrect results, assertions and crashes. | |
| ==11847== WARNING: In particular, Memcheck on 32-bit programs will fail to | |
| ==11847== WARNING: detect any errors associated with heap-allocated data. |
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 Maybe | |
| bind: (f) -> | |
| if @_value is undefined then Nothing else f(@_value) | |
| ret: (x) -> Just(x) | |
| fmap: (f) -> | |
| if @_value is undefined then Nothing else Just(f(@_value)) | |
| Just = (x) -> |
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
| +-------------+-----------------------------+ | |
| | God tier | Functional programming | | |
| +-------------+-----------------------------+ | |
| | Top tier | Logic programming | | |
| +-------------+-----------------------------+ | |
| | Middle tier | Imperative programming | | |
| +-------------+-----------------------------+ | |
| | Shit tier | Object-oriented programming | | |
| +-------------+-----------------------------+ | |
| | Shit crap | PHP | |
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
| foo() -> | |
| Object = spawn(?MODULE, bar, [42]), | |
| Object ! {add, 42}, | |
| Object ! {get, self()}, | |
| receive | |
| Num -> io:printf("~s~n", [Num]) % prints 84 | |
| end. | |
| bar(Num) -> |
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
| module Coroutine | |
| ( Coroutine(..) | |
| ) where | |
| import Prelude hiding (id, (.)) | |
| import Control.Applicative | |
| import Control.Arrow | |
| import Control.Category | |
| newtype Coroutine i o = Coroutine { runC :: i -> (o, Coroutine i o) } |
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 FunctorIO f where | |
| fmapIO :: f a -> IO (f b) | |
| data Input = Input Time Random Keyboard Mouse Joystick | |
| data State = State {shizzle} | |
| data Output = Output | |
| data Game a = Game State a | |
| instance FunctorIO Game 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
| map' :: (Int -> a -> b) -> [a] -> [b] | |
| map' = map'' 0 | |
| where map'' :: Int -> (Int -> a -> b) -> [a] -> [b] | |
| map'' _ _ [] = [] | |
| map'' i f (x:xs) = (f i x) : map'' (succ i) f xs |
NewerOlder