Skip to content

Instantly share code, notes, and snippets.

View ianmbloom's full-sized avatar
👺
.

Ian Bloom ianmbloom

👺
.
  • Norway
View GitHub Profile
module util (T:numeric) = {
type t = T.t
let sqr (x:t):t = x * x
let clampRange (mn:t) (mx:t) (v:t):t = T.max mn (T.min mx v)
-- Take in input x in range from 0 to 1 and transform it linearly to a value y, clamped in a range from low to high.
let outputRange (start:t)
( end:t)
( x:t):
t =
let slope = end - start
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module GeoPred.BinaryFile
( createOrLoadBinaryFile
)
where
import Prelude hiding ((!))
import qualified Data.ByteString.Lazy.Char8 as BS
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module GeoPred.BinaryFile
( createOrLoadBinaryFile
)
where
import Prelude hiding ((!))
import qualified Data.ByteString.Lazy.Char8 as BS
@ianmbloom
ianmbloom / gist:eb0e7feebb77635e82e3be45c19bb497
Created October 28, 2019 21:00
Trying a polymorphic vector zip.
data Zip f a = P {unP :: a} | V {unV :: f a}
deriving (Eq, Ord, Read, Show, Functor)
instance MonadZip f => Applicative (Zip f) where
pure = P
P f <*> P x = P (f x)
P f <*> V xs = V (f <$> xs)
V fs <*> P x = V (($x) <$> fs)
V fs <*> V xs = V (mzipWith ($) fs xs)