Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
-- I am designing an API. This is not real haskell code, but it is accepted by my tool.
-- I can define type sigs as usual
query :: Query a -> System -> [a]
-- I can also write laws that the eventual implementation must satisfy.
-- lines that begin with a string are laws.
-- notice that these are _not even_ haskell definitions, because the LHS is not a pattern.
"1" queryEntity ix (refine (const False) q) s = Nothing
"2" queryEntity ix (refine (const True) q) = queryEntity ix q
@isovector
isovector / Main.hs
Last active June 24, 2020 15:30
eta reduction repro
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PatternSynonyms #-}
module Main where
import GHC.Generics
import Data.Void
import Control.Applicative
import Control.Arrow
import Control.Monad.Trans.State
test =
DifferenceR3 0.0
( UnionR3 0.0
[ Translate3 (0.0, 0.0, -6.0) (Translate3 (-7.0, -7.0, -6.0) (CubeR 0.0 (14.0, 14.0, 12.0)))
, UnionR3 0.0
[ UnionR3 0.0
[ Translate3 (0.0, 0.0, -5.0) (Translate3 (-5.0, -5.0, -5.0) (UnionR3 0.0 []))
, UnionR3 0.0 [UnionR3 0.0 [], UnionR3 0.0 []]
]
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
module StateChart
( SC(SC)
@isovector
isovector / StateChart.hs
Last active May 9, 2021 20:20
statechart2.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
-- typechecking goes really fast if you uncomment this line
-- {-# OPTIONS_GHC -fmax-valid-hole-fits=0 #-}
module SlowTypecheck where
import HsExpr
{
"haskell.serverExecutablePath": "/home/sandy/prj/hls/.stack-work/install/x86_64-linux-tinfo6/95210f202fcc608b16b9b498dd9af8f1b8d43ff153fe428a250346ccc0cf33e5/8.8.4/bin/haskell-language-server",
"haskell.formatOnImportOn": false,
"haskell.plugin.tactics.config.features": "QrfgehpgNyy/HfrQngnPba/ErsvarUbyr/XabjaZbabvq/RzcglPnfr/QrfgehpgCha/Zrgncebtenz",
"window.zoomLevel": 1,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
prepropEquivInterpreters
:: forall effs x r1 r2
. (Eq x, Show x, Inject effs r1, Inject effs r2, Members effs effs)
=> (forall a. Sem r1 a -> IO a)
-> (forall a. Sem r2 a -> IO a)
-> (forall r. Members effs r => Gen (Sem r x))
-> Property
prepropEquivInterpreters int1 int2 mksem = property $ do
SomeSem sem <- liftGen @effs @x mksem
pure $ ioProperty $ do
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
import qualified Data.Set as S
import Data.Set (Set)
import Data.Char (isLower)
import Data.Ord (comparing, Down (Down))
import Data.List (sortBy, subsequences, minimumBy, maximumBy)
import Control.Monad.Trans.Writer.CPS
import Data.Monoid
import Data.Foldable (traverse_)
wordFilter :: String -> Bool