Difference between revisions of "Obfuscation"

From HaskellWiki
Jump to: navigation, search
(Found results for 1993 bottomth hocc)
(Change the links for the 2003 and 2004 contents to point to the proper pages in the Wayback Machine)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Obfuscation =
 
 
 
Haskell is (perhaps surprisingly) an excellent language for code
 
Haskell is (perhaps surprisingly) an excellent language for code
 
obfuscation. There have been three Haskell obfuscation contests:
 
obfuscation. There have been three Haskell obfuscation contests:
   
* [http://www.haskell.org/pipermail/haskell/2004-August/014387.html Bottomth Obfuscation Haskell Contest]
+
* [http://www.haskell.org/pipermail/haskell/2004-August/014387.html 1993 Bottomth Obfuscation Haskell Contest]
* [http://www.scannedinavian.org/iohcc/zeroth-2003/ 2003 Zeroth Obfuscated Haskell Contest]
+
* [http://web.archive.org/web/20060103040156/http://iohc.mgoetze.net/ 2003 Zeroth Obfuscated Haskell Contest]
* [http://www.scannedinavian.org/iohcc/succzeroth-2004/ 2004 Succ Zeroth Obfuscated Haskell Contest]
+
* [http://web.archive.org/web/20060107141532/http://www.scannedinavian.org/iohcc/succzeroth-2004/ 2004 Succ Zeroth Obfuscated Haskell Contest] (2004 IOHCC [[Obfuscation/IOHCC 2004|announcement]])
   
 
The ability to use symbols for identifiers helps a lot of course, as
 
The ability to use symbols for identifiers helps a lot of course, as
does suspending the use of layout. Point-free style is also an excellent
+
does suspending the use of layout. [[Pointfree]] style is also an
help. Use of strange monads and type trickery can all be very confusing.
+
excellent help. Use of strange monads and [[type arithmetic]] can all be
Finally, Haskell's clean semantics makes refactoring code
+
very confusing. Finally, Haskell's clean semantics makes refactoring
(semi-)mechanical, leading to some interesting obfuscated encodings (one
+
code (semi-)mechanical, leading to some interesting obfuscated encodings
can rewrite all keywords with lambda abstractions for example).
+
(one can replace most Haskell keywords with lambda abstractions, for
  +
example).
   
 
== Example ==
 
== Example ==
Line 21: Line 19:
 
this case multiple '?' characters), Haskell may be highly obfuscated.
 
this case multiple '?' characters), Haskell may be highly obfuscated.
   
  +
<haskell>
 
--------------------------------------------
 
--------------------------------------------
 
module Main where{import List;import System;
 
module Main where{import List;import System;
Line 59: Line 58:
 
;(?????????????)(???)=(((readFile)((???))))}
 
;(?????????????)(???)=(((readFile)((???))))}
 
--------------------------------------------
 
--------------------------------------------
  +
</haskell>
   
 
[[Category:Idioms]]
 
[[Category:Idioms]]
  +
[[Category:Contests]]

Latest revision as of 18:50, 17 May 2008

Haskell is (perhaps surprisingly) an excellent language for code obfuscation. There have been three Haskell obfuscation contests:

The ability to use symbols for identifiers helps a lot of course, as does suspending the use of layout. Pointfree style is also an excellent help. Use of strange monads and type arithmetic can all be very confusing. Finally, Haskell's clean semantics makes refactoring code (semi-)mechanical, leading to some interesting obfuscated encodings (one can replace most Haskell keywords with lambda abstractions, for example).

Example

The following illustrates how, by turning off layout, rewriting keywords (let, case, where) as lambdas, and using symbols for identifiers (in this case multiple '?' characters), Haskell may be highly obfuscated.

 --------------------------------------------
 module Main where{import List;import System;
 import Data.HashTable as H;(???????)=(concat
 );(??????)(???)(????)=((groupBy)(???)(????))
 ;(??????????????????????)(????)=((??????????
 )((tail).(???????))((????????????????????)((
 ??????)(?????????????????????)(????))));(??)
 =([' ']);(??????????????)=((hashString));(?)
 =((>>=));(???????????????????????)([((???)),
 (????)])=((?????????????)(???))?(\(?????)->(
 (????????????????)(==)(??????????????))?(\((
 ???))->((??????????????????)(???????????????
 )(???)(?????))>>((?????????????????)(???))?(
 \((?????))->((((???????????????????)((????))
 ((??????????????????????))((?????))))))));((
 ???????????????????????))(??)=(????????????)
 ("usage f dic out");(?????????????????????)(
 (???),(??????))((????),(????????????????????
 ))=((???)==(????));(?????????????????)(???)=
 (toList)(???);(????????????????????)(????)=(
 ((??????????)(((??????????)(snd)))((????))))
 ;(??????????????????)(???????????????)(???)(
 (?????))=(((mapM)(((???????????????)(???)))(
 (lines)(?????))));(???????????????????)(????
 )(???????????????????????)(?????)=(?????????
 )(????)((unlines)((???????????????????????)(
 ?????)));(????????????????)(???)((????))=(((
 new)(???)(????)));(main)=((???????????)?(((\
 (???)->((???????????????????????)(???))))));
 (???????????????)(???)(????)=((????????)(???
 )((sort)(????))((??)++(????)));(???????????)
 =(getArgs);(????????????)(???)=((((print))((
 ???))));(??????????)(???)(????)=(((map)(???)
 (????)));(????????)((???))(????)(?????)=((((
 H.insert))((???))(????)(?????)));(?????????)
 ((???))((????))=(((writeFile)(???)((????))))
 ;(?????????????)(???)=(((readFile)((???))))}
 --------------------------------------------