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
data Length = forall x. Length { unLength :: [x] } | |
instance Eq Length where | |
(==) (Length []) (Length []) = True | |
(==) (Length (_:xs)) (Length (_:ys)) = Length xs == Length ys | |
(==) _ _ = False | |
instance Ord Length where | |
compare (Length []) (Length []) = EQ | |
compare (Length (_:_)) (Length []) = GT |
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 Data.BKTree where | |
import Prelude hiding (lookup) | |
import Text.Printf | |
data BKTreeData d a where | |
Node :: a -> [(d, BKTreeData d a)] -> BKTreeData d a | |
deriving Show | |
insertWithMetric :: (Eq d, Num d) => (a -> a -> d) -> a -> BKTreeData d a -> BKTreeData d a | |
insertWithMetric metric val t@(Node nodeVal children) |
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 NoStarIsType #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
module Data.Vector.Sized where | |
import Prelude hiding (take, map) | |
import Data.Vector (Vector) | |
import Data.Vector qualified as Vec | |
import Data.Kind |
OlderNewer