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 RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE GADTs #-} | |
| module Main where | |
| import Data.Map (Map) | |
| import Data.Type.Equality | |
| import Data.Typeable (Typeable) | |
| import Type.Reflection |
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 Day3 where | |
| import Data.List ( isPrefixOf ) | |
| import Data.List.Split ( splitOn ) | |
| import Data.Char ( isDigit ) | |
| run :: IO () | |
| run = do | |
| instructions <- readFile "./data/day3/input" | |
| let tuples = parseInstructions instructions |
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
| correlation :: T.Text -> T.Text -> DataFrame -> Maybe Double | |
| correlation first second df = do | |
| (UnboxedColumn (f :: VU.Vector a)) <- getColumn first df | |
| (UnboxedColumn (s :: VU.Vector b)) <- getColumn second df | |
| Refl <- testEquality (typeRep @a) (typeRep @Double) | |
| Refl <- testEquality (typeRep @b) (typeRep @Double) | |
| let n = VG.length f | |
| let | |
| go (-1) acc = acc | |
| go i (mX :: Double, mY :: Double) = go (i - 1) (mX + f VU.! i, mY + s VU.! i) |
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 DataFrame where | |
| -- Column space with a closed type universe. | |
| data Column = CInt [Int] | |
| | CDouble [Double] | |
| | CString [String] | |
| instance Show Column where | |
| show (CInt xs) = show xs | |
| show (CDouble xs) = show xs |
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 OverloadedLabels #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE ImportQualifiedPost #-} | |
| module Main (main) where | |
| import Chart | |
| import Data.Text (Text) | |
| import Prelude as P |
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 LambdaCase #-} | |
| {-# LANGUAGE NumericUnderscores #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| import Control.Monad (when) | |
| import qualified Data.ByteString.Lazy as L | |
| import Data.List (foldl') |
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
| -- Sort of like Java's step builder pattern. | |
| -- https://medium.com/@castigliego/step-builder-pattern-3bcac4eaf9e8 | |
| -- A type that encodes that Y doesn't exist. | |
| data NeedY | |
| -- A type that encodes that a chart is ready. | |
| data Ready | |
| data Plot (s :: *) where |
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 #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveFoldable #-} | |
| {-# LANGUAGE DeriveTraversable #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE ExplicitNamespaces #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE GADTs #-} |
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 LambdaCase #-} | |
| {-# LANGUAGE NumericUnderscores #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| import Control.Monad (when) | |
| import qualified Data.ByteString.Lazy as L | |
| import Data.List (foldl') |
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 #-} | |
| {-# LANGUAGE BangPatterns #-} | |
| module Main where | |
| import qualified Data.ByteString.Char8 as B | |
| import Data.Char (isSpace) | |
| import System.Environment (getArgs) | |
| -- Run commands: |