-- m は暗黙に量化されている
{-
action :: forall m. MonadError OutOfRange m => m Int
-}
action :: MonadError OutOfRange m => m Int
action = undefined
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
-- Overkilling a cute li'l exercise | |
-- https://www.reddit.com/r/haskell/comments/v0mfkl/cute_lil_exercise/ | |
{-# LANGUAGE UnicodeSyntax, TypeOperators, ScopedTypeVariables, RankNTypes #-} | |
{-# LANGUAGE TypeApplications #-} | |
-- (this time without ImpredicativeTypes, but I'm not sure it's better or not) | |
module Isomorphisms2(goal, to, from) where | |
import Prelude hiding (id, (.)) | |
import Control.Category |
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
-- https://twitter.com/mi12cp/status/1753203763211571656 | |
-- https://twitter.com/rsk0315_h4x/status/1753233137629646938 | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
module Main where | |
import Data.IORef | |
-- trait Fn() |
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 RankNTypes #-} | |
module PolymorphicState where | |
{- | |
-- https://twitter.com/Kory__3/status/1737757423673413635 | |
> forall s, a. Monad (a =>> s -> (s, a)) の値って一意なのでしょうか | |
-} |
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 GHC2021 #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE PolyKinds, DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module InfiniteHigherOrderEffect where | |
import Data.Kind (Type) | |
import Data.Functor.Contravariant (Contravariant) |
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 ExplicitForAll #-} | |
-- With MonomorphismRestriction (which is ON by default,) | |
-- any constrained type variable (e.g. `m` in `Monad m`) | |
-- are not generalized | |
{-# LANGUAGE NoMonomorphismRestriction #-} | |
-- MonoLocalBinds prevents generalization of non-top-level binding | |
{-# LANGUAGE MonoLocalBinds #-} | |
-- Compare for |
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
-- This exists so that I haven't made a silly mistake, | |
-- like typo or type mismatch of expressions surrounding equal sign. | |
{-# LANGUAGE TypeOperators #-} | |
module Check where | |
import Prelude hiding (zip) | |
import Data.These | |
import Data.Zip | |
import Data.Bifunctor |
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
-- https://www.reddit.com/r/haskell/comments/z9eyu7/monthly_hask_anything_december_2022/izpv48z/ | |
{-# language | |
DeriveGeneric, | |
DerivingVia, | |
StandaloneDeriving, | |
TypeOperators, | |
FlexibleInstances, | |
ScopedTypeVariables, | |
TypeFamilies, | |
TypeApplications, |
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
module Foldl(foldl', foldl'Copied, foldl'CopiedMono, foldl'Recursion, foldl'Recursion2) where | |
import Data.List (foldl') | |
import GHC.Exts (oneShot) | |
foldl'Copied :: Foldable t => (b -> a -> b) -> b -> t a -> b | |
{-# INLINE foldl'Copied #-} | |
foldl'Copied f z0 = \ xs -> foldr (\ (x::a) (k::b->b) -> oneShot (\ (z::b) -> z `seq` k (f z x))) (id::b->b) xs z0 | |
foldl'CopiedMono :: (b -> a -> b) -> b -> [a] -> b |
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 GADTs, DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
module Main where | |
import Data.Typeable (cast) | |
import Type.Reflection |
NewerOlder