a |
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 DeriveFoldable, DeriveFunctor, FlexibleContexts, KindSignatures, RankNTypes, TypeFamilies #-} | |
module Main where | |
import Data.Bifunctor | |
newtype F f a = F { runF :: forall r. (a -> r) -> (f r -> r) -> r } | |
wrap :: Functor f => f (F f a) -> F f a | |
wrap f = F (\ p i -> i (fmap (\ (F r) -> r p i) f)) |
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, FlexibleContexts, FlexibleInstances, GADTs, MultiParamTypeClasses, PolyKinds, TypeOperators #-} | |
module FieldSet where | |
infix 9 :=> | |
-- | We can probably replace this with a wrapper around `Tagged`. | |
newtype a :=> b = (:=>) b | |
deriving (Eq, Show) | |
-- | “Smart” (actually quite dumb) constructor for the tagged type above for convenience | |
field :: 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
-- Old friends. | |
newtype Fix f = Fix { unFix :: f (Fix f) } | |
data Free f a = Free (f (Free f a)) | Pure a | |
data Cofree f a = a :< f (Cofree f a) | |
-- A recursive functor. We can’t define a Functor instance for e.g. `Fix` because: | |
-- 1. Its type parameter is of kind (* -> *). Maybe PolyKinds could hack around this, I’ve not tried. | |
-- 2. Following from that, its type parameter is applied to `Fix f` itself, and thus `(f (Fix f) -> g (Fix g)) -> Fix f -> Fix g` would probably be a mistake too; we want to ensure that `Fix` recursively maps its parameter functor into the new type, and not leave that map the responsibility of the function argument. | |
class RFunctor f | |
where rmap :: Functor a => (a (f b) -> b (f b)) -> f a -> f 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
data Parser a where | |
Cat :: Parser a -> Parser b -> Parser (a, b) | |
Alt :: Parser a -> Parser b -> Parser (Either a b) | |
Rep :: Parser a -> Parser [a] | |
Map :: Parser a -> (a -> b) -> Parser b | |
Bnd :: Parser a -> (a -> Parser b) -> Parser b | |
Lit :: Char -> Parser Char | |
Ret :: [a] -> Parser a | |
Nul :: Parser a | |
Eps :: Parser 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
'use babel'; | |
import {Range} from 'atom'; | |
atom.commands.add('atom-text-editor', 'editor:select-outside-brackets', function () { | |
const editor = atom.workspace.getActiveTextEditor(); | |
const initial = editor && editor.getSelectedBufferRange().freeze(); | |
atom.commands.dispatch(editor.element, 'bracket-matcher:select-inside-brackets'); |
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
newtype Term f = In { out :: f (Term f) } | |
-- The trivial one | |
type RCoalgebra1 f a = a -> f (Either (Term f) a) | |
apo1 :: Functor f => RCoalgebra1 f a -> a -> Term f | |
apo1 f = In . (fmap fanin) . f | |
where fanin = either id (apo1 f) | |
a |
b |
a && b |
---|---|---|
👎 | 👎 | 👎 |
👍 | 👎 | 👎 |
👎 | 👍 | 👎 |
👍 | 👍 | 👍 |
Interpreting parseNull
as the least fixed point of the parse null equations, ascending from ⊥ = {}
Given S → ϵ↓{x} ∪ S
,
The zeroth iteration is ⊥
:
parseNull⁰(S) = ⊥ = {}
The first is computed:
Interpreting δ
as the least fixed point of the nullability equations, ascending from ⊥ = false
.
Given S → ϵ ∪ S
,
The zeroth iteration is ⊥
:
δ⁰(S) = ⊥ = false
The first is computed: