Skip to content

Instantly share code, notes, and snippets.

View ajnsit's full-sized avatar
🚕
Places to go, things to do

Anupam <|> अनुपम ajnsit

🚕
Places to go, things to do
View GitHub Profile
@ajnsit
ajnsit / EDSL_Compilation.lhs
Created March 30, 2016 13:42 — forked from emilaxelsson/CompleteMatching.hs
Compilation as a Typed EDSL-to-EDSL Transformation
---
title: Compilation as a Typed EDSL-to-EDSL Transformation
author: Emil Axelsson
colorlinks: blue
link-citations: true
header-includes:
include-before:
---
@ajnsit
ajnsit / comment.txt
Created March 30, 2016 12:49
Relationship between Operational, Free, and Coyoneda
From Edward's comment here - https://www.reddit.com/r/haskell/comments/4cfxri/relationship_between_operational_monad_and_oleg/d1hxmfr
You can view Operational f as sugar for Free (Coyoneda f).
Coyonedamakes a functor out of anything of kind * -> *. This is good and bad, depending on how you use the result. If you inspect it multiple times and do more fmap's etc, you may wind up lifting and lowering repeatedly and converting back and forth between f and Coyoneda f does require an fmap on the roundtrip.
Similarly, Free makes a monad by using any Functor worth of instructions.
These notions compose very naturally. Now your 'instructions' don't have to start as a Functor, they just get to be anything of kind * -> *.
@ajnsit
ajnsit / loeb.md
Created March 30, 2016 07:48 — forked from PkmX/loeb.md
Löb with error handling

Löb with error handling

löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:

loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
  where xs = fmap ($ xs) fs
@ajnsit
ajnsit / Spirals.hs
Created March 29, 2016 07:06
ASCII Spirals in Haskell
type Elem = [String]
width :: Elem -> Int
width e
| (c:_) <- e = length c
| otherwise = 0
height :: Elem -> Int
height = length
@ajnsit
ajnsit / Insult.hs
Created September 5, 2015 07:56
Insult generator in Haskell
{-# LANGUAGE DeriveDataTypeable, QuasiQuotes #-}
module Main where
import Data.Char (toUpper)
import Data.List (intersperse)
import Data.String.Interpolate (i)
import System.Environment (getArgs)
main :: IO ()
main = getArgs >>= putStrLn . makeInsult
@ajnsit
ajnsit / .cabal config
Last active August 29, 2015 14:24 — forked from kgadek/.cabal config
-- This is the configuration file for the 'cabal' command line tool.
-- The available configuration options are listed below.
-- Some of them have default values listed.
-- Lines (like this one) beginning with '--' are comments.
-- Be careful with spaces and indentation because they are
-- used to indicate layout for nested sections.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
-- What is the big deal? Took all of 2 minutes to write this
module Main where
main :: IO ()
main = mapM_ (putStrLn . fizzbuzz) [1..100]
fizzbuzz :: Int -> String
fizzbuzz x = divisors `orElse` show x
where
divisors = concatMap test [(3,"Fizz"),(5,"Buzz"),(7,"Baz")]
@ajnsit
ajnsit / getting_real_synopsis
Created November 8, 2013 10:41
"Getting Real" book synposis
Getting Real
============
URL
---
http://gettingreal.37signals.com/
Synposis
--------