# Functions not data structures

Sometimes the best way to represent data is using a function.

Church encoding can be used to represent any algebraic data type using only functions.

Another example is the following, not very efficient, implementation of a FiniteMap:

```type FiniteMap key elt = key -> Maybe elt

emptyFM :: FiniteMap key elt
emptyFM = \k' -> Nothing

addToFM :: (Eq key) => FiniteMap key elt -> key -> elt -> FiniteMap key elt
addToFM m k v = \k' -> if (k == k') then Just v else m k'

delFromFM :: (Eq k) => FiniteMap key elt -> key -> FiniteMap key elt
delFromFM  m k = \k' -> if (k == k') then Nothing else m k'

lookupFM :: (Eq k) => FiniteMap key elt -> key -> Maybe elt
lookupFM m k = m k
```

Runtime compilation uses functions not data structures to implement an interpretation layer.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5389491,"math_prob":0.99328214,"size":810,"snap":"2020-10-2020-16","text_gpt3_token_len":208,"char_repetition_ratio":0.17741935,"word_repetition_ratio":0.15231788,"special_character_ratio":0.2777778,"punctuation_ratio":0.097222224,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99374056,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-09T04:59:31Z\",\"WARC-Record-ID\":\"<urn:uuid:e00a4f48-d6d8-4968-9f1d-781973423c1d>\",\"Content-Length\":\"16370\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2788a91d-ee1f-4924-bc02-0daa85717917>\",\"WARC-Concurrent-To\":\"<urn:uuid:af5c9a74-c242-4b7d-aaa5-5070691cfd13>\",\"WARC-IP-Address\":\"151.101.201.175\",\"WARC-Target-URI\":\"http://wiki.haskell.org/Functions_not_data_structures\",\"WARC-Payload-Digest\":\"sha1:3Y6M7WF6JFUHENXKMSDSKVLOV7Z6G2XG\",\"WARC-Block-Digest\":\"sha1:3ES3ZE4H7ER35LE3RXVLXYOWWKH5OTXF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585371829677.89_warc_CC-MAIN-20200409024535-20200409055035-00531.warc.gz\"}"}