Here's a simple query with variable interpolation:
getBadge
:: MonadIO m
=> BadgeId
-> SqlPersistT m [Entity BadgeEvent]
getBadge badgeId =
[sqlQQ|
SELECT
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} |
-- An unserious response to | |
-- | |
-- > I will believe in type systems the day one of them warns me about this code: | |
-- > pub fn add_two_integers(num1: Int, num2: Int) -> Int { | |
-- > num1 - num2 | |
-- > } | |
-- | |
-- I don't understand why people don't want to program like this. Types! | |
{-# LANGUAGE AllowAmbiguousTypes #-} |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE StrictData #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
import Control.Monad.State | |
import Data.Map.Strict (Map, (!)) | |
import qualified Data.Map.Strict as Map | |
import Prelude hiding (log, sum) |
Here's a simple query with variable interpolation:
getBadge
:: MonadIO m
=> BadgeId
-> SqlPersistT m [Entity BadgeEvent]
getBadge badgeId =
[sqlQQ|
SELECT
#!/usr/bin/env stack | |
-- stack --resolver lts-10.8 script | |
-- Serializing and deserializing GADTs by using an intermediate | |
-- untyped representation. | |
-- | |
-- Typed | List [And (Not (Equals (Int 1) (Int 2))) (Equals (Bool True) (Bool False)),Bool False] | |
-- Annotated | List [And (Not (Equals (Int 1) (Int 2))) (Equals (Bool True) (Bool False)),Bool False] ::: ListTy BoolTy | |
-- Erased | UList [UAnd (UNot (UEquals (UInt 1) (UInt 2))) (UEquals (UBool True) (UBool False)),UBool False] | |
-- Encoded | "{\"List\":[{\"And\":[{\"Not\":{\"Equals\":[{\"Int\":1},{\"Int\":2}]}},{\"Equals\":[{\"Bool\":true},{\"Bool\":false}]}]},{\"Bool\":false}]}" |
#!/usr/bin/env stack | |
-- stack --resolver lts-10.3 script --package ghc-typelits-natnormalise | |
{- | |
$ tail -2 Vector.hs | |
print $ toVector @[1, 2, 3, 4, 5] | |
print $ toVector @["whomp", "merp", "yarp"] | |
$ ./Vector.hs |
/* @flow */ | |
export type ChurchT<A> = <R>(cons: (a: A, r: R) => R, nil: () => R) => R | |
function fromArray<A>(array: Array<A>): ChurchT<A> { | |
return function<R>(cons: (a: A, r: R) => R, nil: () => R): R { | |
let result = nil() | |
for (let i = array.length - 1; i >= 0; --i) { | |
result = cons(array[i], result) | |
} |
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
import Control.Monad | |
import Control.Exception | |
import GHC.Exts | |
import GHC.IO | |
import GHC.Prim |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Data.Typeable | |
import Control.Monad | |
import Control.Exception | |
import Prelude hiding (id) |
diff --git a/rts/Compact.cmm b/rts/Compact.cmm | |
index 72ad4dd437..a4b2d9b2ef 100644 | |
--- a/rts/Compact.cmm | |
+++ b/rts/Compact.cmm | |
@@ -121,17 +121,49 @@ eval: | |
} | |
// We shouldn't see any functions, if this data structure was NFData. | |
+ | |
+ case |