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
newtype Atom = | |
Atom Word64 | |
preview :: Atom -> (Maybe Bool, Word64) | |
preview x = | |
let raw = coerce x | |
f = shorten raw | |
in if | testBit raw 63 -> (Nothing, f) | |
| testBit raw 62 -> (Just False, f) | |
| otherwise -> (Just True, f) |
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
newtype AtomP = AtomP Word64 | |
view :: AtomP -> Maybe (Bool, Word64) | |
view x = let mask = complement (bit 63 .|. bit 62) | |
raw = coerce x in | |
if | testBit raw 63 -> Nothing | |
| testBit raw 62 -> Just (False, pext64 raw mask) | |
| otherwise -> Just (True, pext64 raw mask) | |
-- I want to expose a view of AtomP as a Maybe (Bool, Word64) on the basis of the function above. |
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
-- Suppose these are the mappings: | |
mappingsAsList :: [((Int,Int), Bool)] | |
mappingsAsList [((1,2), True), ((1,3), False), ((1,4), True), | |
((2,4), True), ((2,5), False), ((2,6), True)] | |
-- I wanna be able to efficiently request 'give me all mappings where the first part of the key is x'. | |
-- For instance, if I asked for x = 1, I should get [((1,2), True), ((1,3), False), ((1,4), True)] | |
-- I also wanna be able to efficiently request 'give me all mappings where the second part of the key is y'. | |
-- For instance, if I asked for y = 4, I should get [((1,4), True), ((2,4), True)] |
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 DataKinds, DeriveFunctor, GADTs, KindSignatures, | |
ScopedTypeVariables, TemplateHaskell, TypeFamilies, | |
TypeApplications #-} | |
module Data.Massiv.Array.Sized.One where | |
import CoercibleUtils | |
import Data.Coerce | |
import Data.Finite | |
import Data.Foldable |
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.Vector.Unboxed as V | |
data Categorical = -- some definition of a type here | |
data Discrete = -- some definition of a type here | |
data Continuous = -- some definition of a type here | |
type family ColumnData a where | |
ColumnData Categorical = V.Vector Word32 |
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 DeriveGeneric #-} | |
{-# LANGUAGE DuplicateRecordFields #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
module Data.CRLF where | |
import GHC.Generics | |
import Control.Monad.Except | |
import Data.Binary |
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
arr = [5, 8, 11, 0] | |
function bitat(x,i) | |
x & (1 << (i - 1)) != 0 | |
end | |
y = BitMatrix(bitat(arr[i], j) for i in 1:4, j in 1:4) | |
#= | |
This fails, claiming: | |
MethodError: Cannot `convert` an object of type Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},UnitRange{Int64}},##9#10} to an object of type BitArray{2} |
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
augroup ghciMaps | |
au! | |
au FileType haskell nnoremap <silent> <leader>gs :GhciStart<CR> | |
au FileType haskell nnoremap <silent> <leader>gk :GhciKill<CR> | |
au FileType haskell nnoremap <silent> <leader>gr :GhciRestart<CR> | |
au FileType haskell nnoremap <silent> <leader>go :GhciOpen<CR> | |
au BufWritePost *.hs GhciReload | |
au BufWritePost *.hs GhciReload | |
let g:ghci_command = 'stack repl' | |
let g:ghci_command_line_options = '--ghci-options="-fobject-code -Wall"' |
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
-- I'm trying to write up a schema for an SQLite database storing some data sets | |
-- Requirements are as follows: | |
-- 1) Every data set has a unique name | |
-- 2) Every data set has multiple attributes associated with it | |
-- 3) Every attribute has several possible values | |
-- 4) Attributes may be class attributes or non-class attributes | |
-- 5) Every record is associated with one data set | |
-- 6) Every record must have exactly one value for every attribute associated with its data set | |
-- | |
-- Now, I can get as far as point 4 with the following: |
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
! You can't use `\prevdepth' in horizontal mode. | |
\nointerlineskip ->\prevdepth | |
-\@m \p@ | |
l.286 \end{slide} |
NewerOlder