Skip to content

Instantly share code, notes, and snippets.

@noinia
noinia / dummy.hs
Created September 17, 2020 11:20
static compilation ghc
module Main where
main = print "woei"
@noinia
noinia / foldr.hs
Created May 8, 2020 18:26
foldr1 with basecase function?
foldr1With :: Foldable1 f => (a -> b -> b) -> (a -> b) -> f a -> b
foldr1With f b = go . toNonEmpty
where
go (x :| xs) = case NonEmpty.nonEmpty xs of
Nothing -> b x
Just xs' -> x `f` (go xs')
@noinia
noinia / quickcheck.hs
Last active February 16, 2020 15:04
QuickCheck Weirdness?
import qualified Data.Set as Set
import Test.QuickCheck
import Debug.Trace
setOf :: (Ord a, Show a) => Int -> Gen a -> Gen (Set.Set a)
setOf n g = buildSet mempty <$> infiniteListOf g
where
buildSet s xs | traceShow (take 10 xs) False = undefined
buildSet s (x:xs) | length s == n = s
@noinia
noinia / stack error microlens
Created October 25, 2017 22:12
stack error microlens
frank@UU# stack install -v
Version 1.5.1 x86_64
Compiled with:
- Cabal-1.24.2.0
- Glob-0.8.0
- HUnit-1.6.0.0
- MonadRandom-0.5.1
- QuickCheck-2.10.1
- SHA-1.6.4.2
- StateVar-1.1.0.4
@noinia
noinia / stack error
Last active October 25, 2017 15:04
stack build error
frank@UU# rm -rf ~/.stack
frank@UU# stack setup
Writing implicit global project config file to: /home/frank/.stack/global-project/stack.yaml
Note: You can change the snapshot via the resolver field there.
Using latest snapshot resolver: lts-9.10
Downloaded lts-9.10 build plan.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
@noinia
noinia / CairoSimple.hs
Last active August 10, 2017 08:26
Simple gi-gtk + Cairo "hello world"-like application.
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Exception (catch)
import Control.Monad (forM_)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Trans.Reader (runReaderT)
import Data.GI.Base
@noinia
noinia / CairoSimple.hs
Created August 10, 2017 08:25
Simple Cairo
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Exception (catch)
import Control.Monad (forM_)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Trans.Reader (runReaderT)
import Data.GI.Base
@noinia
noinia / CairoSimple.hs
Created August 10, 2017 08:25
Simple Cairo
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Exception (catch)
import Control.Monad (forM_)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Trans.Reader (runReaderT)
import Data.GI.Base
@noinia
noinia / corecs.hs
Last active August 29, 2015 14:22
CoRec as Open Union
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
module CoRecExtra where
import Data.Maybe(isJust, mapMaybe, listToMaybe, fromJust)
import Data.Proxy
import Data.Vinyl.Core
import Data.Vinyl.Functor
import Data.Vinyl.Lens
@noinia
noinia / TypeLevelSkewTree.hs
Last active August 29, 2015 14:13
Fiddling on type level skewtrees
-- type Height = Int
data SkewTree a = Empty
| InternalNode !(SkewTree a) a !(SkewTree a)
| TopNode !(SkewTree a) a !(SkewTree a) !(SkewTree a)
deriving (Show,Eq)
leaf a = InternalNode Empty a Empty