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 ConstraintKinds #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} |
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
-- | Pattern match on 'HasField' | |
-- | |
-- This is intended to be used together with 'matchHasField'. Example usage: | |
-- | |
-- > data Foo a | |
-- > | |
-- > instance HasField "fooX" (Foo a) Int where .. | |
-- > instance HasField "fooY" (Foo a) [a] where .. | |
-- > | |
-- > _example :: Foo Char -> (Int, [Char]) |
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 #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# OPTIONS_GHC -Wall #-} | |
module TypeLevelComposition 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
newtype Nat (n :: N) = UnsafeInt Int | |
deriving Show via Int | |
data IsNat (n :: N) where | |
IsZero :: IsNat Z | |
IsSucc :: Nat n -> IsNat (S n) | |
toIsNat :: Nat n -> IsNat n | |
toIsNat (UnsafeInt 0) = unsafeCoerce IsZero | |
toIsNat (UnsafeInt n) = unsafeCoerce (IsSucc (UnsafeInt (pred n))) |
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 #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} |
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
#!/bin/bash | |
if [ ! -n "$1" ]; then | |
export ACTIVATED="" | |
if [ -n "$PRE_ACTIVATED_PATH" ]; then | |
export PATH="$PRE_ACTIVATED_PATH" | |
unset PRE_ACTIVATED_PATH | |
fi |
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 ConstraintKinds #-} | |
{-# OPTIONS_GHC -Wno-redundant-constraints #-} | |
module edundantConstraints ( | |
keepRedundantConstraint | |
) where | |
-- | Can be used to silence individual "redundant constraint" warnings | |
-- | |
-- > foo :: ConstraintUsefulForDebugging => ... |
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 RecordWildCards #-} | |
module SoundSeries.Util.SoupParser ( | |
SoupParser | |
, parseSoup | |
-- * Combinators | |
, satisfy | |
, anyToken | |
, skipUntil | |
, lookupAttr |
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
-- | Recover tree structure from linearized form | |
-- | |
-- Suppose we have a list of strings | |
-- | |
-- > A | |
-- > B | |
-- > C | |
-- > D | |
-- > E | |
-- > 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
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# OPTIONS_GHC -Wall #-} | |
import Control.Monad.Reader | |
import Data.Coerce | |
import Test.QuickCheck.Gen | |
import Test.QuickCheck.Monadic |