This file contains 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
ghci> duration @"P1Y1W" | |
Duration {years = 1, months = 0, days = 0, weeks = 1, hours = 0, minutes = 0, seconds = 0} | |
ghci> duration @"P1Y1WT10H5M" | |
Duration {years = 1, months = 0, days = 0, weeks = 1, hours = 10, minutes = 5, seconds = 0} | |
ghci> duration @"P1Y1WT10H5M120S" | |
Duration {years = 1, months = 0, days = 0, weeks = 1, hours = 10, minutes = 5, seconds = 120} | |
ghci> duration @"P10H5M120S" | |
<interactive>:119:1: error: | |
• Cannot parse duration. Expecting 'T', got: 10H5M120S |
This file contains 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 StandaloneDeriving #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE GADTs #-} | |
import GHC.Generics | |
import Data.Data (Data, Typeable) | |
data Tag = TagA | TagB | |
data MyGADT t where |
This file contains 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
cases :: [a] -> String | |
cases _ = "Hello" | |
fiz = \cases l -> cases | |
main = do | |
putStrLn $ fiz "Chien" [] |
This file contains 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
locFromECP :: ECP -> PV SrcSpan | |
locFromECP e = locA . getLoc <$> unECP e | |
{- | |
1. Defined but not used: ‘locFromECP’ | |
2. • Ambiguous type variable ‘t0’ arising from a use of ‘unECP’ | |
prevents the constraint ‘(DisambECP (t0 GhcPs))’ from being solved. | |
Probable fix: use a type annotation to specify what ‘t0’ should be. | |
These potential instances exist: | |
instance DisambECP (PatBuilder GhcPs) |
This file contains 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 TypeApplications #-} | |
{-# LANGUAGE BangPatterns #-} | |
import Control.Arrow | |
fact :: Int -> IO Int | |
fact = go 1 | |
where | |
go acc 0 = pure acc | |
go !acc n = do | |
putStrLn "Yada" |
This file contains 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 MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
class Fold f t acc | f -> t acc where | |
foldLR :: Foldable foldable => f -> acc -> foldable t -> acc | |
instance Fold (t -> acc -> acc) t acc where | |
foldLR = foldr | |
instance Fold (acc -> t -> acc) t acc where |
This file contains 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
#include <iostream> | |
class Callback | |
{ | |
public: | |
virtual void call() = 0; | |
}; | |
Callback *registered_callback; |
This file contains 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 TypeApplications #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# OPTIONS -Wall -Wredundant-constraints #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ConstrainedClassMethods #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE UndecidableInstances #-} |
This file contains 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 TypeApplications #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE ConstraintKinds #-} |
This file contains 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 ViewPatterns #-} | |
import System.Process | |
import qualified Data.Text as Text | |
import qualified Data.Text.IO as Text | |
import Data.Foldable (for_) | |
import Data.Char (isLower) | |
import Control.Monad (when) | |
import Control.Applicative ((<|>)) |
NewerOlder