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 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 |
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 ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
module GeoPred.BinaryFile | |
( createOrLoadBinaryFile | |
) | |
where | |
import Prelude hiding ((!)) | |
import qualified Data.ByteString.Lazy.Char8 as BS |
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 ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
module GeoPred.BinaryFile | |
( createOrLoadBinaryFile | |
) | |
where | |
import Prelude hiding ((!)) | |
import qualified Data.ByteString.Lazy.Char8 as BS |
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 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) |