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
| digraph G { | |
| KRC -> Miranda; | |
| ML -> Miranda; | |
| KRC -> SASL; | |
| SASL -> Miranda; | |
| Miranda -> Haskell; | |
| Hope -> Haskell; | |
| ML -> Caml; | |
| Caml -> FSharp; | |
| Clean -> Haskell; |
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
| {-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-} | |
| module Handler.Root where | |
| import FortuneSearch | |
| import Search | |
| import Data.Text (Text) | |
| import qualified Data.Text as T | |
| import Yesod.Json |
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
| module Search ( | |
| getKeyValues | |
| , parseQuery | |
| , query | |
| ) where | |
| import FortuneIndexer (getTerm) | |
| import qualified Data.Text as T | |
| import Database.Redis.Redis |
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
| {-# LANGUAGE OverloadedStrings #-} | |
| module FortuneIndexer ( | |
| getTerm | |
| ) where | |
| import Control.Monad (forM_) | |
| import Data.List.Split (splitOn) | |
| import Data.Char (isLetter, isSpace) | |
| import Data.Text.Encoding as E |
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
| import qualified Data.Text.IO as T | |
| import Data.List.Split (splitOn) | |
| splitOnPercent :: T.Text -> [T.Text] | |
| splitOnPercent = T.splitOn "%" | |
| splitOnBlankLines :: T.Text -> [T.Text] | |
| splitOnBlankLines t = (init . map T.concat) (splitOn [" "] (T.lines t)) | |
| fortunes :: [(FilePath,T.Text -> [T.Text])] |
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
| import qualified Data.Text as T | |
| import Text.ParserCombinators.Parsec | |
| import Text.ParserCombinators.Parsec.Combinator | |
| import Text.ParserCombinators.Parsec.Char | |
| import Text.ParserCombinators.Parsec.Expr | |
| import Text.ParserCombinators.Parsec.Token | |
| import Text.ParserCombinators.Parsec.Language | |
| import Text.ParserCombinators.Parsec.Error | |
| data Query = Contains T.Text |
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
| compareLists :: [String] -> [String] -> Int -> [(String,String)] | |
| compareLists x y dist = nearest | |
| where | |
| -- Hashes | |
| hashX = map (computeHash . FV) x | |
| hashY = map (computeHash . FV) y | |
| -- Lookups | |
| nameX = zip hashX x | |
| nameY = zip hashY y | |
| nearest = [(fromJust $ lookup hx nameX |
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
| -- http://www.mail-archive.com/haskell-cafe@haskell.org/msg10223.html | |
| instance Arbitrary Word64 where | |
| arbitrary = do | |
| let mx,mn :: Integer | |
| mx = fromIntegral (maxBound :: Word64) | |
| mn = fromIntegral (minBound :: Word64) | |
| c <- choose (mx, mn) | |
| return (fromIntegral c) |
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
| hammingDistance2 :: Word64 -> Word64 -> Int | |
| hammingDistance2 a b = f 0 (a `xor` b) | |
| where | |
| f c v | v == 0 = c | |
| | otherwise = f (c + 1) (v .&. (v - 1)) |
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
| hammingDistance :: Word64 -> Word64 -> Int | |
| hammingDistance a b = length $ filter (\x -> testBit a x /= testBit b x) [0..63] |