For an ADT type, such as,
data Exp = Num Int | App Char Exp
deriving (Show)In Haskell we have case expressions to deconstruct values, and they have exhaustiveness checking. We have
| find ~/Work -name stack.yaml | xargs grep -o '^resolver: \([^#]*\)' |
| newtype Decode a = | |
| Decode | |
| { runDecode :: ByteString -> (a, ByteString) | |
| } | |
| deriving (Functor) | |
| instance Applicative Decode where | |
| (<*>) = ap | |
| pure = return | |
| {-# INLINE (<*>) #-} | |
| instance Monad Decode where |
| fix :: (a -> a) -> a | |
| fix f = let x = f x in x | |
| on :: (b -> b -> c) -> (a -> b) -> a -> a -> c | |
| (.*.) `on` f = \x y -> f x .*. f y | |
| (&) :: a -> (a -> b) -> b | |
| x & f = f x |
| chris@precision:~/Work/chrisdone/prana$ docker run -v`pwd`:`pwd` -w`pwd` --rm ghc-compile sh -c "find /root/ghc_build -name '*.prana' -exec ls -lh {} \;" | |
| -rw-r--r-- 1 root root 939 Jan 18 14:02 /root/ghc_build/ghc-8.0/libraries/base/base_GHC.Err.prana | |
| -rw-r--r-- 1 root root 9.8K Jan 18 14:03 /root/ghc_build/ghc-8.0/libraries/base/base_GHC.Event.TimerManager.prana | |
| -rw-r--r-- 1 root root 9.7K Jan 18 13:59 /root/ghc_build/ghc-8.0/libraries/base/base_Data.Bifunctor.prana | |
| -rw-r--r-- 1 root root 9.5K Jan 18 14:00 /root/ghc_build/ghc-8.0/libraries/base/base_Data.Type.Coercion.prana | |
| -rw-r--r-- 1 root root 9.4K Jan 18 14:05 /root/ghc_build/ghc-8.0/libraries/base/base_GHC.IO.Device.prana | |
| -rw-r--r-- 1 root root 88 Jan 18 14:01 /root/ghc_build/ghc-8.0/libraries/base/base_Foreign.Marshal.Unsafe.prana | |
| -rw-r--r-- 1 root root 80K Jan 18 14:07 /root/ghc_build/ghc-8.0/libraries/base/base_GHC.RTS.Flags.prana | |
| -rw-r--r-- 1 root root 8.8K Jan 18 14:05 /root/ghc_build/ghc-8.0/libraries/base/base_GHC.IO.Buffer.prana | |
| -rw-r--r-- 1 roo |
Repo Staleness Issues Stale issues Avg. last update
commercialhaskell/hindent 89.80% 49 44 288.08 days
commercialhaskell/intero 47.06% 17 8 71.47 days
chrisdone/jl 83.33% 6 5 126.00 days
fpco/odbc 100.00% 5 5 174.40 days
chrisdone/lucid 0.00% 5 0 2.40 days
haskell-perf/sequences 100.00% 2 2 95.00 days
haskell-perf/dictionaries 100.00% 1 1 158.00 days
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE PartialTypeSignatures #-} | |
| {-# LANGUAGE ParallelListComp #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE DisambiguateRecordFields #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE OverloadedStrings #-} |
In his talk
Maybe Not,
Rich Hickey explores a way of thinking about data in terms of the
functions that work on them, rather than baking in any assumptions
into the system directly. He's trying to take his spec system in
this direction. I also have a keen interest in moving over to using
records more often in typed Haskell-like languages.
An example from the slides was:
| main = print (fib 5) | |
| fib 0 = 0 | |
| fib 1 = 1 | |
| fib n = fib (n-1) + fib (n-2) |
| {-# LANGUAGE GADTs #-} | |
| data Tree a where | |
| OneT :: Show a => a -> Tree a | |
| Ap :: (Show a, Show b) => (a -> b -> c) -> Tree a -> Tree b -> Tree c | |
| instance Show a => Show (Tree a) where | |
| show (OneT a) = show a | |
| show (Ap _ x y) = "" ++ show x ++ "," ++ show y ++ "" |