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
| defmodule Lookup do | |
| @wordfile "words.txt" | |
| @external_resource @wordfile | |
| @times 1_000_000 | |
| @words @wordfile |> File.stream! |> Enum.map(&String.strip/1) | |
| @hash_set Enum.into(@words, HashSet.new) | |
| @map_set Enum.into(@words, MapSet.new) |
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
| # | |
| # TypeBully forces functions to respect their typespecs by rewriting the function clauses to include proper guards. | |
| # | |
| # For example, the Wimp module below: cry/3 has typespecs, but no enforcing guards, normally, calling cry/3 would | |
| # always match the first function clause, but TypeBully forces it to select the correct one based on its typespec. | |
| # | |
| # | |
| # Without TypeBully: | |
| # | |
| # iex(1)> Wimp.cry("whaa") |
OlderNewer