Let's define a type class Searchable.
class Searchable a where
epsilon :: (a -> Bool) -> a
-- [Law]
-- (∃x :: a. p a == True) => p (epsilon p) = True
We want to show that the following instance is valid.
| Test by executing this line at shell: | |
| $ for i in {1..10}; do ./unix-lock.hs & done |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| -- For the "Another take" | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE FunctionalDependencies #-} |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module Main(main) where | |
| import Data.Proxy | |
| class Same x y where |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| {-# LANGUAGE InstanceSigs #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| module Set where | |
| import Data.List (nub, elem) |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE DefaultSignatures #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE QuantifiedConstraints #-} | |
| module AutoLift( |
| name: bundle | |
| version: 0.1.0.0 | |
| synopsis: Solve bundling problem | |
| -- description: | |
| homepage: https://github.com/minkless/sudoku#readme | |
| license: BSD3 | |
| license-file: LICENSE | |
| author: Koji Miyazato | |
| maintainer: [email protected] | |
| copyright: Koji Miyazato |
Let's define a type class Searchable.
class Searchable a where
epsilon :: (a -> Bool) -> a
-- [Law]
-- (∃x :: a. p a == True) => p (epsilon p) = True
We want to show that the following instance is valid.
(I didn't think of kind polymorphism and don't know how that relates to FlexibleInstances)
-- Fixed is owned
| class Foo() | |
| // フィールドが一つもないクラスを定義し、そのクラスのオブジェクトを作ると | |
| // コンパイラ自体がSegmentation Faultを起こす | |
| //@one_field = 0 | |
| @function g() | |
| ans = "0" | |
| return ans | |
| x = Foo() |
| {- | |
| @lexi_lambda (at twitter) | |
| https://mobile.twitter.com/lexi_lambda/status/1192930938537332736?s=19 | |
| -} | |
| {-# LANGUAGE RankNTypes #-} |