Skip to content

Instantly share code, notes, and snippets.

View lgastako's full-sized avatar

John lgastako

  • Francon & Heyer
  • Milky Way Galaxy, Third Rock from the Sun
View GitHub Profile
@lgastako
lgastako / SelfServe.hs
Created May 23, 2018 09:45
Anonymous Records in Haskell (via SuperRecord) Example
#!/usr/bin/env stack
-- stack --resolver lts-9.21 --install-ghc runghc --package aeson --package lens --package protolude --package safe --package servant --package superrecord --package text --package time --package warp
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
module ParserExperiment
( statementParser
) where
import Control.Applicative ( (<*) )
import Data.Functor ( (<$) )
import Text.Parsec
import Text.Parsec.Char ( upper )
type Identifier = String
module BinChar
-- %default total
-- Binary literals
data BinChar : Char -> Type where
O : BinChar '0'
I : BinChar '1'
data Every : (a -> Type) -> List a -> Type where
main = interact $ show . f . map read . words
f (n:a:b:c:_)
| b - a == c - b = arith !! n
| otherwise = geo !! n
where
arith = [a, b ..]
geo = if diffsigns || increasing
then a:map (*d) geo
else a:map (`div` e) geo
main = interact $ show . f . map (map read . words) . lines
f :: [[Int]] -> Int
f ([n]:xs:_)
| isArith xs = nthArith n xs
| otherwise = nthGeom n xs
isArith :: [Int] -> Bool
isArith (a:b:c:_) = b - a == c - b
property running : False
property checkInterval : 30
on run
tell application "System Events"
if (exists application process "zoom.us") then
running = True
end if
end tell
end run
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Lambda.Parser where
import Viper.Prelude
import Data.Attoparsec.Text
import Data.Eq.Deriving ( deriveEq1 )
module SwipeCodes where
import Data.List
-- [x] Between 5 to 8 "digits"
-- [x] At least 1 horizontal line was filled
-- [x] It spanned all 3 horizontal lines
-- [x] It spanned all 3 vertical
-- [x] It started downward (may have come back up)
-- [x] You can't use the same node twice and
module SwipeCodes where
import Data.List
-- [x] Between 5 to 8 "digits"
-- [x] At least 1 horizontal line was filled
-- [x] It spanned all 3 horizontal lines
-- [x] It spanned all 3 vertical
-- [x] It started downward (may have come back up)
-- [x] You can't use the same node twice and
1
1 2
1 2 3
1 2 3 5
1 2 3 5 4
1 2 3 5 4 7 8 6 9
1 2 3 5 4 7 8 9 6
1 2 3 5 6
1 2 3 5 6 9 8 4 7