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
<?php | |
class Functions { | |
public static function getScope() { | |
// Here I had to instantiate the class twice, or the static method would not be callable (???) | |
return ['Functions\Inner' => new \Functions\Inner((new \Function\Inner([]))::getScope()) ]; | |
} | |
public function __construct($scope) { | |
if ($scope !== []) { | |
$this->scope = $scope; |
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
// Generated by purs version 0.13.8 | |
"use strict"; | |
var bar2 = 3; | |
var bar1 = function (x) { | |
return x; | |
}; | |
module.exports = { | |
bar1: bar1 | |
}; |
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
-- Halogen 4 | |
data State = { started :: Boolean, choice :: String } | |
data Query = Start | Choose String | |
component :: Monad m => H.Component HH.HTML Query Unit Void m | |
component = | |
H.component | |
{ initialState: const { started: false, choice: "" } |
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
#! /usr/bin/env nix-shell | |
#! nix-shell -p haskellPackages.ghcid | |
#! nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [req casing comonad])" | |
#! nix-shell -i "ghcid -W -c 'ghci -Wall' -T main" | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} |
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
-- first I want to select some elements to display in my table | |
select $ from $ \(foo `innerJoin` bar) -> do | |
on (foo ^. FooBar ==. bar ^. BarId) | |
where_ (foo ^. FooFoo ==. E.val True) | |
orderBy [asc (foo ^. FooId)] | |
offset (resultsPerPage * pageNum) | |
limit resultsPerPage | |
pure (foo, bar) | |
-- then I want to count the total to know how many pages are there |
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
type MyRecord = { foo :: String, bar :: Instant } | |
decodeinsomeway :: Int -> Either String Instant | |
decodeinsomeway i = eitherturnintintoinstantornot i | |
decodeMyRecord :: Json -> Either String MyRecord | |
decodeMyRecord json = do | |
tempRecord <- decodeJson json -- this is decoded as { foo :: String, bar :: Int } | |
newField <- decodeinsomeway tempRecord.bar | |
pure $ tempRecord { bar = newField } |
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
... | |
postFile :: forall b. ReadForeign b => URL -> FormData -> Aff (E b) | |
postFile url content = do | |
cookie <- liftEffect getXSRFToken | |
defaultRequest' <- sDefaultRequest | |
let req = Record.merge defaultRequest' defaultRequest | |
req' = Record.delete (SProxy :: SProxy "retryPolicy") req | |
res <- try $ request $ req' { method = Left POST | |
, url = url | |
, content = Just $ RequestBody.formData content |
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
module Components.Form.Search where | |
import Prelude | |
import Bulma as B | |
import Component.Utils.Debounced (DebounceTrigger, cancelDebounceTrigger, debouncedEventSource, runDebounceTrigger) | |
import Data.Foldable (for_) | |
import Data.Maybe (Maybe(..)) | |
import Data.String (length, null) | |
import Effect.Aff (Aff, Milliseconds) |
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
module Component.Utils.Debounced where | |
import Prelude | |
import Data.Either as E | |
import Data.Foldable (traverse_) | |
import Data.Maybe (Maybe(..)) | |
import Effect.Aff.AVar as AVar | |
import Effect.Aff (Milliseconds, delay, forkAff, killFiber) | |
import Effect.Aff.Class (class MonadAff, liftAff) |
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
-- let's ignore negative inputs | |
sub1 :: Int -> Int | |
sub1 0 = throw $ SomeException 0 | |
sub1 n = n - 1 | |
countDown :: Int -> IO Int | |
countDown n = countDown (sub1 n) `catch` \(SomeException n') -> pure n' |
NewerOlder