Uniform Boilerplate and List Processing Or: Scrap Your Scary Types Neil Mitchell and Colin Runciman, Haskell Workshop, 2007 Simple generics (Haskell ’98)

Download Uniform Boilerplate and List Processing Or: Scrap Your Scary Types Neil Mitchell and Colin Runciman, Haskell Workshop, 2007 Simple generics (Haskell ’98)

Post on 12-Jan-2016

217 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

Retrieving re-usable software components by polymorphic type

Uniform Boilerplate andList ProcessingOr: Scrap Your Scary TypesNeil Mitchell andColin Runciman,Haskell Workshop, 2007Simple generics (Haskell 98)

Huttons Razor++data Exp = Lit Int | Neg Exp | Add Exp Exp | Sub Exp Exp | Mul Exp Exp | Div Exp ExpWhat literals are in an expression?Change all Sub to Add/Neg?Literals in an expressionliterals (Lit i ) = [i]literals (Neg x ) = literals xliterals (Add x y) = literals x ++ literals yliterals (Sub x y) = literals x ++ literals yliterals (Mul x y) = literals x ++ literals yliterals (Div x y) = literals x ++ literals yUniplate in actionWhat literals are in an expression?

Change all Sub to Add/Neg?literals x = [i | Lit i ([a], [a] -> a)

universe :: Uniplate a => a -> [a]transform :: Uniplate a => (a -> a) -> a -> aclass Data a where gfoldl :: (forall d b. Data d => c (d -> b) -> c b) -> (forall g. g -> c g) -> a -> c aCompared to Scrap Your Boilerplate (SYB):UniplateGeniplateLensesreformulatedperformanceMLTraversalrefactoredCurryportedMultiplateusedportedrestrictedSemiplateApplications (48 on Hackage)HLint Haskell linting toolReduceron FPGA compilerSupero Haskell optimiserHoogle Haskell search engineNSIS Windows installer generatorScion IDE backendTamarin prover Security theorem proverCodo notation Comonad notationYi text editorRetrieving re-usablesoftware componentsby polymorphic typeColin Runciman andIan Toyn, JFP, 1991Lets define a type-based search engine!

Mikael Rittri, Using Types as Search Keys in Function Libraries. FPCA 1989... recent developments inso-called hypertext systems ...Hooge (2003-), (2007-)Web based, Haskell serversName and type-based searchSearch 8,457 functionsvs 203 in 1991Many company-local copiesInstant reports if it goes down!Integrated in FP Complete IDEPeople were paid to work on it

What should match?In what order?Not too slowhttp://haskell.org/hoogle(a -> a -> a) -> [a] -> aHooge(a -> a -> a) -> [a] -> afoldl1, foldr1(a -> a -> a) -> [a] -> [a] scanl1, scanr1Foldable t => (a -> a -> a) -> t a -> a foldl1, foldr1(a -> a -> Ordering) -> [a] -> a minimumBy(a -> b -> a) -> a -> [b] -> afoldl(a -> b -> b) -> b -> [a] -> bfoldr(a -> a -> Bool) -> [a] -> [a]nubBy(a -> a -> a) -> [a] -> aHoogeHooge Usage

I would love to update this, but the log file is now 8.4Gb~30 million searches since 2009Funny SearchesColin Runciman:: Colin Runcimaneastenderscalifornia public schools portable classesdiem chuan truong dai hoc su pham ha noi 2008ebay consistency versionvideos pornos gratisGia savores de BARILOCHEname of Peanuts cartoon bird

Recommended

View more >