Database records and formlets and optionally populated records can be neatly all represented with the same data type when the fields are all indexed.
class Indexed i a where
type Index i (a :: *)| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE UnsaturatedTypeFamilies #-} | |
| import GHC.TypeLits | |
| import Prelude hiding (Functor, Semigroup) | |
| type Main = (Fizz <> Buzz) <$> (0 `To` 100) |
| {-# LANGUAGE BlockArguments #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| module Halp where |
| #lang racket | |
| ;; this is a stand alone simple version of the closure conversion part of the hoist pass from the tarot compiler | |
| ;; see https://rain-1.github.io/scheme for more. | |
| (require data/queue) | |
| ;; closure conversion for lambda calculus | |
| ;; | |
| ;; the input language is: |
| module Data.Labelled.Tree where | |
| -- Traditionally, we express a rose tree with a structure along the lines of | |
| -- | |
| -- ``` | |
| -- data RoseTree a | |
| -- = RoseTree a (Array (RoseTree a)) | |
| -- ``` | |
| -- | |
| -- As with many of our favourite "Haskell containers", this comes with an |
I was implementing "variable-arity zipWith" from Richard Eisenberg's thesis (recommended) when I noticed it used
apply :: [a -> b] -> [a] -> [b]
apply (f:fs) (a:as) = f a : apply fs as
apply _ _ = []and
repeat :: a -> [a]| {-# LANGUAGE AllowAmbiguousTypes #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE InstanceSigs #-} | |
| {-# LANGUAGE PatternSynonyms #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE RankNTypes #-} |
| module LensExample where | |
| import Prelude | |
| import Data.Array (filter) | |
| import Data.Generic.Rep (class Generic) | |
| import Data.Generic.Rep.Show (genericShow) | |
| import Data.Lens (Traversal, traversed, wander, (.~), (^..), (+~)) | |
| import Data.Traversable (traverse) | |
| import Effect (Effect) |
| {-# language | |
| TypeInType, GADTs, RankNTypes, TypeFamilies, | |
| TypeOperators, TypeApplications, | |
| UnicodeSyntax, UndecidableInstances | |
| #-} | |
| import Data.Kind | |
| import Data.Proxy | |
| data Nat = Z | S Nat |